5

I'm working on a library project that Blackberry Java developers can import into their projects. It uses protected RIM APIs which require that it be code-signed, which I have done. But, I can't get my Jar imported and working with a simple helloWorld app. I'm using the eclipse plug-in Blackberry-JDE.

EDIT : Solution found....

since I found the solution I removed the things I've tried, leaving only the solution ...

BUILDING THE SDK/Libary (use BB-ANT-TOOLS, either in eclipse or standalone)
steps:

A) I had to build my SDK's jar as an 'cldc' application not as a 'library'
project, using BB-ANT-TOOLS. This solved most of the issues I had above.

B) I then added an ANT task to take the resulting JAR from step A and do the following:

  • unzip it,
  • edit the manifest file to remove the line "MicroEdition-Profile: MIDP-2.0" -- This line causes an error when you try to mark the jar for export.
  • then re-zipped the jar.

NOTE: I wrote a chopped down BB-ANT-TOOLS ant script to show how you could use it to do these two steps above. The script is included below.

Consuming the SDK jar as an end-user or in your own project.
Then to integrate the jar in bb-eclipse you do the following:

A) Add the jar to the BuildPath

B) under "Java Build Path" on the "Order and Export" tab, Select the jar for export. This causes rapc to build the jar into the COD file, so that you only have one COD at the end.

now when a user builds this project the jar become integrated into the final cod file, and it's very easy to deliver to the phone or sim.

<?xml version="1.0" encoding="UTF-8"?>
<project name="XXXXXMobileLib" default="full" basedir=".">
    <description>
  Description: Builds the BBLIB. Uses bb-ant-tools to build, sign and package for blackberry. 
    </description>

    <taskdef resource="bb-ant-defs.xml" classpath="BIN/BB_ANT_lib/bb-ant-tools.1.x.x.jar" />
    <property environment="env" />

    <!-- User defined Vars -->
    <property name="builderRoot" value="." />
    <property name="SIG_PASSWORD" value="XXXXXXXXX" />
    <property name="javaHome" value="${env.JAVA_HOME}" />
    <echo>${javaHome}</echo>
    <property name="jdehome" value="${env.BBJDE_HOME}\" />
    <property name="simulator" value="${jdehome}\simulator" />
    <property name="bin" value="${jdehome}\bin" />
    <property name="releaseBuildOut" value="${builderRoot}\release_out\" />
    <property name="srcBuildOut" value="${builderRoot}\srcBuild_out\" />
    <property name="JarFixTemp" value="${builderRoot}\.tempZip\" />
    <property name="buildVersion" value="${env.BUILD_VERSION}" />

    <property name="application_id" value="com.XXXXX.foo.bar.${buildVersion}" />
    <property name="application_name" value="XXXXX BBLIB v${buildVersion}" />
    <property name="application_desc" value="XXXXX BBLIB v${buildVersion}" />
    <property name="application_vendor" value="XXXXX" />
    <property name="applicaiton_filename" value="XXXXXBBLIB${buildVersion}" />
    <property name="applicaiton_srcs" value="${builderRoot}/src_in_location/" />
    <property name="zipOutName" value="XXXXX-${buildVersion}BBLIB.zip" />
    <property name="zipOutNameJavadocs" value="XXXXX-${buildVersion}BBLIBjavadoc.zip" />

    <property name="jde.home" location="${jdehome}" />

    <!-- 
    MAIN ENTRY TARGET. 
    -->
    <target name="full" depends="clean,javadoc,buildRIM,FixJarManifest,sign,distribute" />

    <target name="FixJarManifest">
        <tstamp/>
        <mkdir dir="${JarFixTemp}"/>
        <unzip src="${builderRoot}/release_out/${applicaiton_filename}.jar" dest="${JarFixTemp}"/>
        <delete dir="${builderRoot}/release_out/${applicaiton_filename}.jar"/>
        <!-- For some reason rapc puts this line into the manifest file, but it breaks the JDE plug-in when you try to
             set the jar for export.  Giving an error like this "Project {0} missing......" 
             To avoid having an empty line in the manifest, Im just injecting a new attribute BuildTime-->
        <replace file="${JarFixTemp}/META-INF/MANIFEST.MF" token="MicroEdition-Profile: MIDP-2.0" value="Build-Time: ${DSTAMP}-${TSTAMP}"/>
        <zip destfile="${builderRoot}/release_out/${applicaiton_filename}.jar"
            basedir="${JarFixTemp}"
        />
        <delete dir="${JarFixTemp}"/>
    </target>

    <!-- Cleanup any existing files in the outdir -->
    <target name="clean">
        <delete>
            <fileset dir="${releaseBuildOut}" includes="**" />
        </delete>
    </target>


    <!-- Generate the Javadocs -->
    <target name="javadoc">
        <javadoc access="public" destdir="${releaseBuildOut}/JavaDocs" author="true" version="true" use="true" defaultexcludes="yes" excludepackagenames="net.rim.*" windowtitle="FOO_BAR">
            <fileset dir="${applicaiton_srcs}/XXXXXMobileLib">
                <include name="src/**/*.java" />
            </fileset>
        </javadoc>
        <zip destfile="${releaseBuildOut}/${zipOutNameJavadocs}" basedir="${releaseBuildOut}/JavaDocs" />
        <delete dir="${releaseBuildOut}/JavaDocs"/>
    </target>

    <target name="buildRIM" description="Builds Project">
        <rapc jdehome="${jdehome}" jdkhome="${javaHome}" destdir="${releaseBuildOut}" output="${applicaiton_filename}" quiet="false">
            <!-- Building as a cldc applicaiton, so it can be packaged up with our final cod, as a single cod -->
            <jdp type="cldc" 
                 title="${application_desc}" 
                 vendor="${application_vendor}" 
                 version="${buildVersion}" 
                 description="${application_desc}" 
                 arguments="" 
                 systemmodule="false" 
                 runonstartup="false" 
                 startuptier="7" 
                 ribbonposition="0">
            </jdp>
            <src>
                <fileset dir="${applicaiton_srcs}/MobileLib">
                    <include name="src/**/*.java" />
                </fileset>
            </src>
        </rapc>
    </target>

    <target name="sign" depends="clean,buildRIM">
        <sigtool password="${SIG_PASSWORD}">
            <fileset dir="${releaseBuildOut}" includes="*.cod" />
        </sigtool>
        <echo>Contents of the signingtool's logfile: </echo>
        <echo file="LogFile.txt" />
    </target>

    <!-- build and distribute the jar -->
    <target name="distribute" depends="buildRIM" description="generate the distribution">
        <alx destdir="${releaseBuildOut}" filename="${applicaiton_filename}.alx">
            <application id="${application_id}" name="${application_name}">
                <codset>
                    <fileset dir="${releaseBuildOut}" includes="*.cod" />
                </codset>
            </application>
        </alx>

        <!-- Create release zip -->
        <delete file="${releaseBuildOut}/${zipOutName}" />
        <zip destfile="${releaseBuildOut}/${zipOutName}">
            <!-- zip up the BB jar and drop it for distribution -->
            <zipfileset dir="${releaseBuildOut}" includes="**/*.jar" />
        </zip>

        <move todir="${releaseBuildOut}/UNUSED_BUILD_OUTPUT_FILES/"><!-- move unwanted files, leaving the zip behind -->
            <fileset dir="${releaseBuildOut}">
                <include name="**/*.*"/>
                <exclude name="**/*.zip"/>
            </fileset>
        </move>
    </target>
</project>
2
  • I was just digging into my logs for my 1.1.1 build of the project and found this error: c:\...\Blackberry-Test-Lib.jar(Blackberry-Test-Lib.cod): Warning!: Import file is marked non-parseable . I'm going to go do research on what that means...
    – eSniff
    May 7, 2010 at 21:19
  • I finally got it working by using BB-ANT-Tools for eclipse and by using the two project method for the Blackberry JDE. Sadly I wasn't able to find a pure Eclipse solution... Here is a good link for the bb-ant-tools slashdev.ca/2007/05/30/blackberry-development-with-ant-eclipse
    – eSniff
    May 15, 2010 at 19:05

1 Answer 1

1

I have used your steps A & B to create a 'library' - thanks. The latest Eclipse plugin for Blackberry (1.3.0.201102031007-19) has a "Blackberry | Package Project" command. I used this to create the jar file (it put it in a 'deliverables' folder in the project).

I then changed the manifest as you suggest to remove MIDP line (which apparently is a known bug). Finally, I followed the steps to add and deploy the lib to my project. (These, btw, are the same steps to adding the Banner / advertising library - very easy.)

I too have a stand-alone / external build script process that uses bb-ant-tools. I recently added the 'external library jar' feature to accommodate this. But using the new feature in Eclipse makes me question if I need to maintain my command-line build scripts as the GUI now does it for me.

The key for me was to switch the build of my library project to a "Blackberry Application" (e.g. CDLC app) as per your instructions. With it set as a 'Library' I was getting that "eviscerated" error.

Thanks for your post.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.