Installing a JAR File on a Phone (Part 1)

OK, say I have, like, a totally super Java ME application. Admittedly, it doesn't do much: It generates a game map and you can walk throught it one-way, but nothing exciting happens. The project compiles and runs with the NetBeans Mobility Pack default phone emulator, and there's a JAR file in the project's dist directory that contains the complete application (even a JAD info file if I needed it). Perfect. Now, I want to see what the app looks like on my mobile phone. But... how does it get there? =-(

The easiest method is Bluetooth file transfer (or of course a direct USB cable, but I have none). I know how to receive files with Bluetooth in Linux, but I can't send them, since I am missing the sending part on the notebook's side... Of course there's the Nokia PC Suite for that. Alas, it's for Windows only.

Before I install PC Suite, I have another idea: MacOS has an Apache webserver... Can't I just go online, write down my temporary IP address, switch on the webserver, drop the JAR file into /Library/WebServer/Documents/, and... use the mobile's webbrowser to download the JAR file? I'd need to pay a fee to establish the GPRS connection, but I only want to try it once anyway...

Well 'once', that's what they all say. Of course the first try fails -- the mobile's browser opens the JAR file as text?! (In retrospect, did I use the wrong menu? My Nokia has an extra menu item for installing applications from a URL, but I used the general browser.) So first I need to make sure my webserver assigns the JAR the correct mime type.

Depending on your webserver, you need to find the mimetype configuration settings: For Apache on MacOS this is for instance /private/etc/httpd/mime.types. You need administrator privileges to edit this file. Add these two lines, one for the type and one for the suffix

text/vnd.sun.j2me.app-descriptor        jad
application/java-archive        jar

Don't forget to restart the webserver to activate the change. In MacOS you restart Apache via the Apple Menu > System Preferences > Sharing by stopping and restarting Personal Web Sharing.

And... Yes, the second download attempt works! (This time, I also made sure to use the mobile's Web > Download menu item instead of Web > Go To Address.) The phone offers me now to install and run the JAR file, if I trust it. Oh my, how exciting!

Result? The game runs! Yay! Only... my game screen is bigger than the mobile's actual screen.. :-( The lower half of the map is cut off... Lukas' tip for resizing the emulator screen works fine (thanks!), but I will bother with optimizing the size settings tomorrow. \*yawn\* In part 2 we will see how far I'll get with the PC Suite and Bluetooth. At least I know now my app works. :-) :-) :-)

Comments:

I've been able to send J2ME midlets to a Sony Ericsson phone via bluetooth, just using the KDE bluetooth module.

..and if you have MacOS 10.4, it's even easier. Bluetooth file exchange is built in. I've used this successfully, too!

What problems are you having, maybe I can help?

Good luck with you game btw.

Pete

Posted by peter on June 20, 2006 at 01:22 PM CEST #

My problems? Mac: Mobility Pack doesn't run on MacOS, the Mac itself is 7 years old, and has no Bluetooth Hardware. Solution: Buy a new one. :) Linux: Can do all the default Java ME compiling stuff and can easily receive Bluetooth transmissions, but I don't know how to send the app to the phone. What's you KDE app called? Windows: Sending an receiving via Bluetooth works fine, but I have to reboot everytime since all my stuff and the IDE etc are in Linux. \*Sigh\* I guess I COULD switch to Windows for the Java ME project...

Posted by Seapegasus on June 22, 2006 at 03:58 AM CEST #

what all you guys' phone modle?

Posted by levin on July 03, 2006 at 02:07 AM CEST #

Mine is a used Nokia 6822. That's the old version of the cool new Nokia E70 that was released just last month! The new one addresses the 6822's major weaknesses, since the E70 finally has lots of memory, an acceptable camera, and a bigger screen. On the other hand, the E70's phone keyboard seems even tinier. http://www.nokia.com/phones/comparephones/compare_results.jsp?location=EN&language=EN&pageaction=COMP&phone=E70&phone=6822

Posted by Seapegasus on July 05, 2006 at 11:35 AM CEST #

Post a Comment:
Comments are closed for this entry.
About

NetBeans IDE, Java SE and ME, 3D Games, Linux, Mac, Cocoa, Prague, Linguistics.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Blogroll