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

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:
- Running Windows xp pro sp2
- download and install the java development kit
- download and install netbeans 6.1 Mobility Pack
- download and install the wireless sun toolkit 2.5.2 so you can emulate your project
- download the specified nokia sdk’s if you like to test it on nokia emulators
- use the nokia sdk install guide (comes with the sdk’s ) to check out how to add these platform into your project ( the install guide offers nice printscreens btw! )
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!



Congratulations,
you make flash lite almost as cool as flex ;)
Just kidding, way go to Thomas!!!
Maarten
June 25, 2008 at 10:26 pm
[...] posted a cool tutorial on how to setup the development enviroment and tips for Jarpa. The Jarpa framework allows to extend [...]
Tutorial: Jarpa packaging for Flash Lite |
June 25, 2008 at 10:33 pm
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
Hi Thomas,
Great job guy! Thanks you very much for sharing this!
Felipe
Felipe Andrade
June 26, 2008 at 12:47 am
[...] Check it out now! Thanks for sharing Thomas! [...]
Felipe Andrade - Flash / Flex / Flash Lite Brasil » Archive » How to package Flash Lite content in a JAR
June 26, 2008 at 1:30 am
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
[...] Here’s the tutorial. [...]
Package your flash lite project into a JAR file | mobbiq blog
June 26, 2008 at 7:49 am
[...] Check it out now! Thanks for sharing Thomas! [...]
[ fla:pik ] Blog » How to package Flash Lite content in a JAR
June 26, 2008 at 1:35 pm
Thanks for sharing!!
susrut316
September 26, 2009 at 1:24 pm