Handling dependencies in blackberry development

前端 未结 4 666
有刺的猬
有刺的猬 2020-12-10 20:28

How can I handle 3rd party dependencies in a .jad file? Is it possible to bundle a .jar? Do you need to unpack it and include the .class

相关标签:
4条回答
  • 2020-12-10 21:01

    See approach of working with kXML2 open source library:

    • for release you have to preverify it & build proj with ant:
      Ahmad Ferdous Bin Alam - How to Import kxml jar File to Your Project
      Slashdev - BlackBerry Development with Ant & Eclipse
      UPDATE:Tutorial: How To Use 3rd Party Libraries in your Applications
    • for debug you have to add kXML sources and org.xmlpull.v1 sources to your BB project
    0 讨论(0)
  • 2020-12-10 21:06

    Can't speak too much for J2ME generically but for BlackBerry you can turn compiled .jar files into .cod files (the BlackBerry binary file format - basically an optimized .jar) and include those along with your application .cod files. You will have to list the additional .cod files in the .jad.

    This link from the BlackBerry knowledgebase should help.

    0 讨论(0)
  • 2020-12-10 21:07

    JAR files can NOT be combined with COD files. You first need to convert these JAR files to COD files (and you should sign them as well). If additional JAR files are supposed to be used as library COD files you need to use the -library switch instead of -midlet for the rapc.exe compiler.

    Once you got your COD files you need to refer in your JAD file to all of the COD files including file sizes. The COD file might look like:

    Manifest-Version: 1.0
    MIDlet-Data-Size: 2048
    MIDlet-Version: 1.4.1
    MIDlet-Jar-Size: 136999
    MIDlet-Icon: /icons/myprogram.png
    MicroEdition-Configuration: CLDC-1.1
    MIDlet-Jar-URL: myprogram.jar
    MIDlet-Name: myprogram
    MIDlet-1: myprogram,/icons/myprogram.png,com.stackoverflow.myprogram
    MicroEdition-Profile: MIDP-2.0
    MIDlet-Vendor: My Company
    Ant-Version: Apache Ant 1.6.5
    Skylab-Build-Number: 2968:2970
    Created-By: 1.5.0_01-b08 (Sun Microsystems Inc.)
    RIM-COD-Module-Dependencies: net_rim_cldc,lib_1,lib_2,lib_3,lib_4,net_rim_locationapi
    RIM-COD-URL: myprogram.cod
    RIM-COD-Size: 77576
    RIM-COD-URL-1: myprogram-1.cod
    RIM-COD-Size-1: 29960
    RIM-COD-URL-2: lib_1.cod
    RIM-COD-Size-2: 28668
    RIM-COD-URL-3: lib_2.cod
    RIM-COD-Size-3: 8712
    RIM-COD-URL-4: lib_3.cod
    RIM-COD-Size-4: 18232
    RIM-COD-URL-5: lib_4.cod
    RIM-COD-Size-5: 12752
    RIM-MIDlet-Flags-1: 0
    RIM-MIDlet-Position-1: 0
    RIM-COD-Module-Name: myprogram
    RIM-MIDlet-NameResourceId-1: 0
    RIM-COD-Creation-Time: 1143020761
    RIM-COD-SHA1: 0b 9f b1 da 47 bc 6f 97 62 eb 32 66 77 ca a9 6f 24 4d 10 8a
    
    0 讨论(0)
  • 2020-12-10 21:19

    If library is not a BlackBerry COD file but a plain MIDP 2.0 JAR file then what you have to do to bundle that with your application is to do the following using the Eclipse JDE plugin:

    1. Right-click your project file and select: "Build Path" > "Configure Build Path...". This will open the Properties screen with "Java Build Path" option showing.
    2. Click on the "Libraries" tab and click "Add JARs..." (or "Add External JARs...") and pick the JAR you want in the next dialog and "OK" it. You should see the JAR that you picked in the list.
    3. Now, click on the "Order and Export" tab and check the checkbox next to the JAR that you added. This makes sure that the build step actually merges this JAR file into your applications output and creates a COD file that includes both.

    The above method works for me but has two problems:

    1. Everytime I change anything related to the "BlackBerry Project Properties" of the project (such as changing the Title or Version of the application), this setting reverts so I have to go through it again. This is a major inconvenience but the steps to follow are not that complicated.
    2. You have to preverify the JAR files that you include as explained in the kXML2 link given in this answer. Failing to do so will result in random verification errors (random in the sense that I don't get them all the time).
    0 讨论(0)
提交回复
热议问题