Thomas Joos | mobile application developer

(re)create your thoughts and expand your limits.

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

9 Responses

Subscribe to comments with RSS.

  1. Congratulations,
    you make flash lite almost as cool as flex ;)
    Just kidding, way go to Thomas!!!

    Maarten

    June 25, 2008 at 10:26 pm

  2. […] posted a cool tutorial on how to setup the development enviroment and tips for Jarpa. The Jarpa framework allows to extend […]

  3. Hi Thomas,

    Interesting post!
    It seems the Jarpa framework does the exact same thing as Sony Ericsson’s announced Project Capuchin: http://developer.sonyericsson.com/site/global/newsandevents/latestnews/newsapr08/p_project_capuchin_announcement.jsp

    Although it’s interesting to have a bridge between J2ME and Flash Lite, it’s still a shame that there’s no common runtime to deliver the same kind of content in a standalone player, without the need for technologies like J2ME and Flash Lite to be available on the mobile device. It will be interesting to see if the Adobe Open Screen Project will push some changes in this direction.

    Imagine you could have a runtime (JVM?) that harnesses the power of J2ME, giving you access to all of the mobile device’s capabilities while being able to run Flash 8 or Flash 9 content…

    It is possible by the way to do all the stuff you described on your Mac, though I must admit it costs a little effort. I’ll write a blog post on the subject on my blog this weekend.

    Regards,
    Sven

    Sven Dens

    June 25, 2008 at 10:57 pm

  4. Hi Thomas,

    Great job guy! Thanks you very much for sharing this!

    Felipe

    Felipe Andrade

    June 26, 2008 at 12:47 am

  5. hi Sven!

    It is possible to run Netbeans Mobility or Eclipse ME but the nokia sdk’s are not available for mac so when you are developing for nokia phones ( the most popular flash lite phones at the moment ) you can not use their sdk’s on a mac and that makes it a pain in the ass.

    Looking forward to you blogpost though!

    vilebody

    June 26, 2008 at 6:32 am

  6. […] Here’s the tutorial. […]

  7. […] Check it out now! Thanks for sharing Thomas! […]

  8. Thanks for sharing!!

    susrut316

    September 26, 2009 at 1:24 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: