Tuesday, February 16, 2010

How to create library jar file and use that jar in another project

Sometimes we use some codes/classes redundantly in many application without any changes in the code.
In such type of cases its better to create a jar file with those classes and use only the jar file on other projects.
For exmaple, if we have some classes with custom UI , then we can create a jar file with the classes rather adding all the classes in other projects repeatdely also in those case we have to change the packge name based on the directory.

First , How to Create the Jar file
-------------------------------
1. Create a new workspace (for example lib.jdw)
2. Create a new project(for example lib.jdp) under lib.jdw
3. Add the classes you want to create jar.
4. Note that no main is reqired.
5. From project properties make the project as library.
    Right Click on the Project -> Properties.. -> Application Tab -> Select Project type as Library
6. Build the project
7. Now you should have a jar file named lib.jar in the project file directory.
8. Preverify the jar file
    a. Go to your JDE installation folder (C:\Program Files\Research In Motion\BlackBerry JDE 
        4.6.0\bin)
    b. Copy lib.jar file to bin folder.
    c. Now open your command prompt and change your current directory to your JDE installation 

        directory.
    d. Now execute the following command:

        preverify -classpath "C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\lib 
        \net_rim_api.jar"  "lib.jar"
    e. In your bin directory(C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\bin) a folder  
        named output will create.
    f. Preverified jar file resides here.


9. Now rename lib.jar as lib.zip and delete cod , csl , cso file from there
10. Rename it back to lib.jar (make sure cod,csl,cso has been deleted)
11. Now you have got the jar file that you can reuse.

Second, How to add this jar to other project
--------------------------------------------
1. For example, yow want to add this jar from another project (different workspace) app.jdp.

2. Import the jar file from the project app.jdp 
    Right Click on the Project -> Properties.. -> Build Tab -> Add lib.jar as Imported Jar    files:
3. Now you will be able to import the classed of lib into the new project app.


Bikas

Saturday, January 9, 2010

How to Deploy any Application on Real Blackberry Devices

First of all the following files are required to install an application into real device.
  a. appName.cod (appName1.cod, appName2.cod, ...)
  b. appName.jad
  c. appName.alx
  d. .htaccess (required for OTA)

An application can be intalled in the real device in two ways.
  a. OTA (Over The Air)
  b. Connecting your device with the PC
      b1. Using Javaloader
      b2. Using Desktop Manager

OTA Installation Process
----------------------------
Check this link.
 
Connecting your device with the PC
---------------------------------------------------------
1. First Connect your device through USB.
2. Sign the cod file if required
3. Then you can install your application in the following ways:
    a. Using javaloader:
        i. Goto the JDE bin directory(ex: C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\bin\).
        ii. copy your cod and jad file there.
        iii. execute the following command from there (you can create a batch file (*.bat) and just click will do )
                javaloader -usb load applicationName.jad           
                                             or
                javaloader -usb load applicationName.cod
    b. Using Desktop Manager:
        i.  Install destop manager
        ii. place *.alx and *.cod  file in the same directory
        iii.select your *.alx file from desktop manager.
        iv.Then it should start installing the application in the device.

Also check out these videos from Developer Video Library.