Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 16
Registered: ‎10-14-2009
My Device: Not Specified
Accepted Solution

rapc and images in the build and command line vs eclipse plugin

Hello,

 

I've been trying to get rapc to compile our project from the command line with a great deal of frustration.  All I want is a compiled COD with images (everything from /res included)  

 

First, the eclipse console output doesn't seem to work exactly when run from the Windows command line, so there's a lot more going on in the background that the plugin is doing.  

 

This is the console output:

 

 

C:\development\eclipse-java-galileo-SR1-win32\eclipse\plugins\net.rim.ejde.componentpack4.5.0_4.5.0.21\components\bin\rapc.exe codename=deliverables\Standard\4.5.0\WCUL deliverables\Standard\4.5.0\WCUL.rapc -sourceroot=C:\development\blackBerry\workspace\Azimuth\src;C:\development\blackBerry\workspace\Azimuth\res;C:\development\blackBerry\workspace\Azimuth\test -import=C:\development\eclipse-java-galileo-SR1-win32\eclipse\plugins\net.rim.ejde.componentpack4.5.0_4.5.0.21\components\lib\net_rim_api.jar;..\MobileDBLibrary\deliverables\Standard\4.5.0\mobileDbLib.jar;..\MicrologLibrary\deliverables\Standard\4.5.0\micrologLoggerCore203.jar;..\AnalyticsLib\deliverables\Standard\4.5.0\flurryAgent12.jar C:\development\blackBerry\workspace\Azimuth\bin

 

Which basically looks like rapc is running against the precompiled classes.  Running this directly from the command line in the same environment:

 

 

...
Warning!: No entry points found
Optimizing
Populating
Warning!: No definition found for exported static routine: .main(String[])
No errors.

 

You get a COD in the output directory, no JAD and trying to load on the device isn't successful (app doesn't appear to be on devicejava)

 

From many posts and from my own experience, it appears that rapc strips out all the images from the binary even though they are included on the path (import, sourcelist, etc).

 

I've tried a workflow of:

 

* compile all source (javac)

* jar classes and resources (images)

* preverify jar

* rapc on the jar

 

This seems to work well, but running on the device -- with all the libraries loaded -- yields 

 

 

Error starting <app>:
Module '<app>-1' has verification error 421 at offset 42e6

 

 

This rapc compiled jar (from the verified jar with all the resources) doesn't contain any of the classes -- just the COD files -- which is a discrepancy from the eclipse rapc jar output.  

 

Somehow the eclipse plugin gets a a successful rapc compile with the resources slipped in at the right moment.  I'd like to know how.  

 

Thanks

 

PS I've tried this with bb-ant-tools and from the command line.  just about 1000 permutations of all of the above

 

 

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: rapc and images in the build and command line vs eclipse plugin

Try this:

1. Create a JAR file containing your .class files and resources (e.g., images).

2. Run RAPC as follows:

java -classpath <path to rapc.jar> net.rim.tools.compiler.Compiler import=<path to net_rim_api.jar> codename=<module name> jad=<JAD name> <path to your JAR>

Developer
Posts: 16
Registered: ‎10-14-2009
My Device: Not Specified

Re: rapc and images in the build and command line vs eclipse plugin

I couldn't get the jar solution working, but that's basically what I was doing with rapc.exe.

 

This post, however, helped a great deal:

 

http://codeforfun.wordpress.com/2008/10/05/how-to-get-images-in-your-cod-for-blackberry/

 

So, after some fiddling, I have it all working:

 

 

  • compile with rapc
  • update jar
  • compile with rapc
  • sign
  • update jad (i have other libraries, use a macrodef here)
Here's some of my ant script using bb-ant-tools, etc.
<target name="[BlackBerry] Compile" depends="[BlackBerry] Build-Libraries">
		<echo message="-- Compiling ${app.name} ${app.version} --"/>

		<!-- rapc precompile -->
		<echo message=">>>>> Rapc Compiling ${src.dir}" />
		<rapc output="${app.output.name}" srcdir="${src.dir}" destdir="${output.dir}"
			importref="mobile.classpath"
			jdehome="${jde.home}" 
			quiet="true" verbose="false" 
			defines="PRODUCTION">
			<jdp title="${app.name}" vendor="CrowdCompass Inc" version="${app.version}" type="cldc" icon="/icon_application_80.png" />
		</rapc>

		<!-- update jar -->
		<echo message=">>>>> Update Jar ${output.dir}/${app.output.name}.jar" />
		<jar destfile="${output.dir}/${app.output.name}.jar" update="true">
			<fileset dir="${resource.dir}"/>
		</jar>

		<echo message=">>>>> Rapc Compiling Jar ${src.dir}" />
		<rapc output="${app.output.name}" destdir="${output.dir}" 
			importref="mobile.classpath" jdehome="${jde.home}" quiet="false" verbose="true" defines="PRODUCTION">
			<jdp title="${app.name}" vendor="CrowdCompass Inc" version="${app.version}" type="cldc" icon="/icon_application_80.png" />
			<src refid="rapc.compile.path" />
		</rapc>

	</target>

	<!-- sign COD -->
	<target name="[BlackBerry] SignCod">
		<echo message="-- Signing ${app.name} --" />
		<sigtool jdehome="${jde.home}" codfile="${output.dir}/${app.output.name}.cod" password="xxxx" />
	</target>

 

 

New Contributor
Posts: 5
Registered: ‎07-09-2010
My Device: Bold 9000
My Carrier: Application development

Re: rapc and images in the build and command line vs eclipse plugin

Hello dshanley

 

It seems you have solved this issue can you please help me for ant build for my project. I am new to java/ant/BB. As per my project requirement I can not use any IDE.

 

So far I can run rapc command but final .cod file is of no use. Javaloader can load and displays "Done" message but nothing is visible inside Download folder of device.

 

For reference I am using command

 

c:\BlackBerry\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components\bin\rapc -quite import=c:\BlackBerry\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components\lib\net_rim_api.jar codename=HelloBB -cldc c:\BlackBerry\workspace\HelloBB\src\com\qz\HelloBB\HelloBB.java c:\BlackBerry\workspace\HelloBB\res

 

 

Where "c:\BlackBerry\workspace\HelloBB" is my working directory.

 

Thanks in Advance.

Mangal

 

mangal.lal@rediffmail.com

 

Contributor
Posts: 40
Registered: ‎07-14-2010
My Device: Not Specified

Re: rapc and images in the build and command line vs eclipse plugin

Can you please explain ? 

<src refid="rapc.compile.path" />
Developer
Posts: 16
Registered: ‎10-14-2009
My Device: Not Specified

Re: rapc and images in the build and command line vs eclipse plugin

I have a couple of paths that I use in our ant script:

 

 

<path id="rapc.compile.path">
		<pathelement location="${output.dir}/${app.output.name}.jar" />
	</path>
	<property name="rapc.compiled.jar.path" refid="rapc.compile.path" />

 and rapc.compile.path points to the jar file output in the first compilation pass.  This is used as input on the second compilation pass which is necessary to include all the images, etc.

 

 

 

Contributor
Posts: 40
Registered: ‎07-14-2010
My Device: Not Specified

Re: rapc and images in the build and command line vs eclipse plugin

Hi,

 

Not require to do below things : 

  • compile with rapc
  • update jar
  • compile with rapc
  • sign
  • update jad (i have other libraries, use a macrodef here)

Solution:

Make sure "srcdir" and "destdir" are refering to same path.

 



Highlighted
New Contributor
Posts: 9
Registered: ‎12-23-2010
My Device: BlackBerry 9000
My Carrier: Fido

Re: rapc and images in the build and command line vs eclipse plugin

If you have your build.xml script, would you be able to show an example. I've tried to get this working for a while and i'm never able to get to this stage. any help would be appreciated