Thomas Joos | mobile application developer

(re)create your thoughts and expand your limits.

Archive for the ‘Jarpa’ Category

Jarpa: How to package your flash lite project into a JAR file

with 9 comments

Jarpa

A while ago I started exploring the new Jarpa Framework. This project is offering a way to package your flash lite project into a JAR file so your application can easily be installed on all types of smartphones!

Even though it sounds simple, most Flash Lite developers are not that familiar with JavaME (at least I’m not) and that makes it a bit difficult to get started. There is no documentation available, just some source code from Felipe and that’s basically it. I think it could be quite handy to have a quick summary of how to get started using Jarpa as a packaging tool.

First things first: you need to set up your development environment: I am using a mac and after a few hours trying a must admit it is a no go. Here is what I came up with:

STEP 1
Setting up your development environment:

it is important to add the sdk’s as a platform to emulate your project. If you have downloaded and installed these tools you are ready to go and give Jarpa a try!

STEP 2
Download and use the Jarpa Classes

  • Download the Jarpa classes and start up a new mobile project in Netbeans.
  • Put the donwloaded classes in the src directory ( make sure to check the class paths to structure your src directory correctly! ) Replace the created Midlet by the Jarpa.java file you downloaded.
  • Read Felipe’s post to take a quick look at the 3 Jarpa files (Jarpa.java; Connection.java; Resources.java)  and see what they do and how they work together.

Step 3
Using Jarpa to package your swf file into a JAR:

If you have downloaded the classes and made a new mobile project in Netbeans there are a few things you should know as a Flash Lite Developer. It basically works like this:

  • The jarpa.java file is a midlet and starts running when clicking the app’s icon once it is installed
  • jarpa.java copies the swf file from the builded jar file (yes with swf included ) onto the device
  • Via the ”platformrequest” command the midlet opens the copied swf file and launches it on top of the java midlet.

More info:
In your netbeans project directory you have some folders like ”src”, ”build”, … etc. There is also a Resources folder. In this folder you need to stash your swf file! Just right click onto this directory and choose ”add Folder” and then browse to the folder where you have saved your swf file. When building and compiling the project, all the files/folders in this Resources directory are being copied into the JAR file (you can find this builded JAR in the ”dist” directory )

When the user starts up the javaME midlet by clicking the icon, Jarpa looks for the swf file in the JAR and copies it to a directory on the phone. Make sure to check if the midlet does find the swf thats being held in the JAR. In Felipe’s source example the Jarpa Midlet finds the swf in a folder named ”res”. This means that a ”res” folder was added to the project’s Resources directory, containing the swf file. When the JAR is build, it copies that res folder. When the Jarpa midlet finds the swf it copies it to file:///E:Others. This is where you need to put your swf file if you are testing on a s60 device like a nokia n95 for example.

After that the jarpa midlet uses the ”platformrequest” command to lauch the copied swf file in the others directory to open your flash lite project on top of the midlet. If the swf file is running fullscreen it just looks like your flash lite project is launching from itself!

Summary

  • Use the 3 Jarpa files to start up a mobile project in netbeans
  • add your swf file in the Resources directory using right click and ”add Folder” (browse to the folder where the swf file is located )
  • Build your project
  • check if the builded JAR in the dist directory contains the folder you added (just open with winrar to check this)
  • if the JAR file contains your folder, make sure the Jarpa Resources class links to this directory ( ‘/res/” in Felipe’s Example this should be replaced with ‘/YourFolder/’
  • Build your project again

Result

You should know have build a JAR file containg an added folder (“res” in Felipe’s Example) which contains your swf file. If you install this JAR onto your target (nokia n95 for example, using the s60sdk) you see an icon added in the applications section. (using netbeans you should be able to configure which icon you would like ) When you click on this icon the Jarpa midlet launches and looks for the added folder in the JAR file to find the swf file and then copies it to the file:///E:Others directory. After that it uses ”platformrequest” to open the copied swf file on top of the midlet.

Congratulations you know have succesfully packaged your flash lite project into a JAR file. I really hope I explained the flow of Jarpa in a clear way. Please be aware Jarpa does not work on every phone. Check the website for more info. You can always leave a comment if you are having trouble getting started, or just follow the Jarpa Google Group or Felipe’s Forum Nokia Blog.

I hope this tutorial reaches out to many Flash Lite developers because I think it is a nice way to package your projects like this. I know Felipe is working on a tool that does the packaging for you. When I was in Toronto Bill showed us an Adobe Packaging Tool doing the same thing. Packaging your swf file into a JAR.

But you do not longer have to wait for these tools and just do it yourself!

Advertisements

Written by vilebody

June 25, 2008 at 10:16 pm

Posted in Flash Lite, Jarpa, Mobile