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
LMcRae
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Netbeans 3rd party lib.

 I have a 3rd party lib that I can get to work with JDE but not NetBeans. The lib has a cod, jar, csl and cso.  Along with code there are some resource images in it.  Since the cod is already built I didn't make a project in JDE and then have my main project depend on it.  Instead I just went into the project properties and imported the jar and then I made a post build step to copy all the lib files to the simulator.  This works fine. 

 

 For NetBeans I add the same jar to my project as a resource and this resolves the imports and allows me to compile.  Like JDE I make sure the lib files get copied to the simulator but when I run the app I get a verification error.  I find this odd since I would expect the lib is already preverified since it has a cod with it.  Still I did run the preverify from the JDE on the jar and it had no errors and created a new jar in the sub-directory called output.  I tried using this preverified version and still had no luck.  Now I am assuming the problem is related to the fact that NetBeans is using javac for everything and only rapc for the jar to cod step where as JDE uses rapc to do all of it.  When I look at the jar NetBeans made I noticed it had all the classes and resources in it from the lib where as the JDE version didn't.

 

 Finally I decided to mimic JDE using the bb-ant-tools and have rapc do everything. This works and I will live with it if I have to but I would like to have it play nice with NetBean so that I don't loose and of the functionallity that the IDE offers.  Right now I will have to override some targets in the default NetBeans build file and I am concerned I will be breaking stuff as my Ant Fu isn't strong.

 

 I have spent a serveral days scowering the net for info but it seems like there isn't one place to get the low down on the whole BlackBerry tool chain.  I would think that this is something that RIM would have documented by now.

 

Any help will be much appreciated.

 

 

Please use plain text.
Developer
LMcRae
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: Netbeans 3rd party lib.

Here is the code I added to my NetBeans build.xml that works and still keeps as much of the IDE features working. Hopefully this will save someone some time.  This was inspired by the following example. I have to say the main reason I really like NetBeans is that it's for the most part a GUI for ant.  I think RIM really needs to document their tool chain fully. I haven't been able to find any references to a .rapc file that can be fed to the rapc.exe.  The only way I know it even exists is by watching the output from JDE.

 

 

<!-- Make sure we have the required tools. --> <target name="post-init"> <available file="${platform.home}/bin/rapc.exe" property="do.rapc"/> <condition property="jpda.port" value="8000"> <isset property="do.rapc"/> </condition> <fail unless="libs.ant-contrib.classpath">Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set.</fail> <taskdef resource="bb-ant-defs.xml"/> <taskdef resource="net/sf/antcontrib/antlib.xml"> <classpath> <pathelement path="${libs.ant-contrib.classpath}"/> </classpath> </taskdef> <!-- This is used a couple of times so I saved it for reuse. --> <patternset id="dist.file.patternset"> <include name="${name}*.cod" /> <include name="${name}*.debug" /> <include name="${name}*.csl" /> <include name="${name}*.cso" /> </patternset> </target> <!-- Things work better if all of the compiling is done using the RIM tool chain. --> <target name="do-compile" depends="create-jad" if="do.rapc"> <!-- Create a list of all the preprocessed files. --> <mkdir dir="${dist.dir}"/> <path id="src-files"> <fileset dir="${preprocessed.dir}" includes="**/*.*"/> </path> <property name="srcs" value="${toString:src-files}"/> <for list="${srcs}" param="file" delimiter=";" trim="true"> <sequential> <echo message="@{file}${line.separator}" file="${dist.dir}/build.files" append="true"/> </sequential> </for> <!-- Create a cod from all the preprocessed files. Note that the jad is being treated as a .rapc file instead of a jad. This was taken from how JDE did it. If not done this way then the focus icon won't work. Change once bb-ant-tools supports the focus icon. --> <exec dir="${basedir}" executable="${platform.home}/bin/rapc.exe" failonerror="true"> <arg value="import=${platform.bootclasspath};${libs.classpath}"/> <arg value="codename=${basedir}/${dist.dir}/${name}"/> <arg value="${basedir}/${dist.dir}/${dist.jad}"/> <arg value="warnkey=0x52424200;0x52525400;0x52435200" /> <arg value="@${basedir}/${dist.dir}/build.files"/> </exec> </target> <target name="post-jar" if="do.rapc"> <!-- Copy the cod and other files needed to simulate and/or debug the app. --> <copy todir="${platform.home}/simulator" overwrite="true"> <fileset dir="${basedir}/${dist.dir}"> <patternset refid="dist.file.patternset"/> </fileset> </copy> </target> <target name="post-clean"> <delete failonerror="false"> <fileset dir="${platform.home}/simulator"> <include name="**/${name}*.*"/> </fileset> <fileset dir="${basedir}/${dist.dir}"> <patternset refid="dist.file.patternset"/> </fileset> </delete> </target> <target name="sign" depends="build" description="Builds and Signs the project."> <sigtool jdehome="${platform.home}" codfile="${basedir}/${dist.dir}/${name}.cod" password="mypassword"> </sigtool> </target> <target name="upload" depends="sign"> <exec dir="${basedir}/${dist.dir}" executable="${platform.home}/bin/javaloader.exe" failonerror="true"> <arg value="-u"/> <arg value="load"/> <arg value="${basedir}/${dist.dir}/${name}.cod"/> </exec> </target>

 

 

 

Please use plain text.