How To Install, Compile, Run Java On iPhone

By Angsuman Chakraborty, Gaea News Network
Tuesday, June 10, 2008

iPhone doesn’t natively support Java / J2ME. However as a J2ME developer there are two good ways to develop iPhone applications using Java / J2ME. Read below for details and also to know how you can upload, compile and run Java applications on iPhone.

alcheMo-for-iPhone - Automated J2ME to iPhone porting solution

alcheMo for iPhone contains translator to convert J2ME application source code to equivalent C++ source code for iPhone.

No manual adjustments to the translated source code is required. Compiled using the standard Xcode toolchain and linked with alcheMo’s optimized run-time library, a native iPhone application is produced.

alcheMo for iPhone is capable of converting J2ME applications utilizing an extensive subset of Java ME CLDC 1.1 and MIDP 2.0 (including touch screen support) and supports several JSR extension APIs including the JSR-256 mobile sensor API. This automatic translation process is instantaneous, repeatable and doesn’t require iPhone specific experience.

Garbage collection and automatic memory management is one of the strengths of the J2ME environment. Unlike on Macintosh OS X, Objective C on iPhone does not support garbage collection. By incorporating an advanced garbage collector, alcheMo eliminates the need for manual memory management. Whole classes of common programming errors such as dangling pointers are thus prevented.

The initial version of alcheMo for iPhone is optimized for mobile games.

The bad news is that their beta program has closed on April 24th, while they are preparing for commercial release. alcheMo for iPhone has backing from Sun Microsystem.

BTW: During Java One 2008, Sun officials repeatedly mentioned that they successfully ran Java on iPhone but are thwarted only by Apple’s licensing restrictions in publicly announcing it. alcheMo circumvents Apple’s licensing restrictions with their language translator.

Using Java on Unlocked & Jailbraked iPhone with Installer

Note: The legality of the procedure below is dubious. IANAL.

First you need to unlock and jailbrake you iPhone. You can use the windows user interface for ZiPhone to jailbreak, unlock and activate any verion of iPhone.

Then you need to have the installer app on iPhone. Installer.app is a UIKit based package manager for the iPhone. It works by downloading packages over WiFi (wireless networking) or EDGE. It supports installing, updating and uninstalling applications from multiple sources.

winpwn can simplify the above steps for you.

Now go to Installer and install Mobile Terminal and Cydia Installer. Restart iPhone.

Run Cydia Installer and go to Java section and select iPhone/Java which will install the virtual machine, libraries etc. Then install Jikes (java compiler). Now restart iPhone again.

That’s it, you are done.

How to load, compile & run Java applications on iPhone

First install Java on iPhone following instructions in the section above before reading this.

You can upload Java files to iPhone using iPhone Browser.
Run Terminal (installed above) and use java (jikes) compiler to compiler your program. For example:
jikes -cp /usr/lib/rt.jar MyFirstJavaProgramForIPhone.java

You can run the class file as usual:
java MyFirstJavaProgramForIPhone

Java on iPhone - Concluding thoughts

The second method (using jailbraked iPhone) suffers from three major problems.
1. To use your Java applications, your user will also have to jailbrake their iPhone. As such its usage will be limited to highly technical people who are not afraid of tinkering with their costly iPhone and potentially even risk damaging it permanently!

2. While it may be fine for experimenting, the legality is dubious. You may run into problem with Apple for selling or even distributing such applications.

3. The jailbraked versions of iPhone may not be compatible with future firmware updates, and Apple will try their best to disable them at every opportunity and had done so in the past.

All of the above makes method 2 unsuitable for commercial use.

Commercial J2ME developers have to wait for commercial release of alcheMo-for-iPhone. Innaworks is well known for porting standards compliant J2ME to BREW mobile platform. I expect their solution to be ready in 2-3 months time. If you do not have the time then download Apple’s iPhone SDK and start coding in Objective C.
BTW: Make sure you read the iPhone SDK agreement carefully before you invest huge sums in iPhone development.

And if You are really interested in Apple iPhone then you must visit our cool collection of iPhone articles. This ranges from How to Increase iPhone Battery Life by 4.5 Hours to 25 iPhone Apps for Designers - Incredibly Useful Collection to Top 10 Green iPhone Apps and even absolutely hilarious 10 Funny iPhone Apps to Annoy your Mother-in-Law. I am sure you will love the collection.

Discussion
December 1, 2010: 4:27 am

It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this.

October 29, 2010: 3:43 pm

hey very good,We can do great earning through ebay affiliation.hank you admin nice blog pages.


Network Marketing
September 15, 2010: 1:45 pm

Thank goodness, the national football league season has begun. what’s everyones choice to win the championship this year? The easy pick is the Pats.

September 1, 2010: 6:39 pm

Hopefully the evacuation of Ocracoke island was not really required and Earl simplystays out at in the ocean. Let us hope for it.

September 1, 2010: 12:54 am

your information about iphone apps is very useful for me thank you.

July 14, 2010: 2:40 am

Don’t have cash to buy some real estate? Worry no more, because it’s achievable to get the loan to work out all the problems. So get a consolidation loan to buy all you need.

July 7, 2010: 12:55 am

Apple A2141 is real headach for me help me for
1.Im getting end call after 5 min while I am speaking on my 3G apple.
2. how to get set with the GPRS cause when I send SMS for Activation it dose not reach the server of BSNL-India.
3. Phone addres nos. are just 10 to 12 nos. rest not shown as on SIM card.. help. 9422396488


AntiAppleDev
June 10, 2010: 4:50 pm

The quote about legality being “dubious” is nonsense. Despite what Apple and even Mr. Jobs may say, they have no rights or control over what you do with the device once you purchase it.

It may void your warranty, and it may violate the ToS of your cell provider, but there is nothing illegal about writing, selling, or using software for the iPhone written in Java.


KIRAN PATEL
May 4, 2010: 6:11 am

how can install software and games in java base midp.2 samsung mobile sgh f-700?

April 14, 2010: 7:00 am

This is really surprising. iPhone does not support Java at all. I just wondered how am I supposed to access certain websites if they require JVM.

April 7, 2010: 5:46 am

Thanks for sharing this post,very interesting.


update
February 8, 2010: 11:56 am

Running Java apps on iPhone seems to have stimulated some brains ^^.
Other legal solutions exist now!
Whereas AlcheMo addresses J2ME only, iSpectrum by FlexyCore provides you with a full Java 1.5 compliant solution along with an Eclipse plugin that allows you develop native iPhone applications.
Check it out at https://www.flexycore.com


Blake
January 18, 2010: 6:30 pm

Trying to put a .jar file on my jailbroken IPhone. File is supposed to unpack and run itself once it is loaded on a java enabled phone. I have java on Iphone through Cydia, now need to move jar file and have it operate. please help.

November 14, 2009: 4:51 am

Sir,
I have bought a iphone copy m003/ java/32GB/3.4″ touch screen/.
I want to install java supported word/ pdf in memory.
have you any software CD to install it .please send me price and shpping in India.
Thanking you
vinod/
contact No- 09977154909


Jeffrey
October 30, 2009: 2:26 am

I got a compass iphone from china MT6235 model A2141 but when i go to internet and open video it will go to another screen written on top is Insufficient…(after the words the others are hidden)and below it state Application
JAVA (4097K) and below shows

BACK STOP

If i press back,it will stuck at a page to load internet
If i press STOP,all Java application will close including my Opera mini and can only be used after i reboot the Phone….Also i cannot save files-the error is no read permission-(what is that)

Can anyone tell me what can i do??


Brian
September 21, 2009: 8:32 am

Hey, this one is a complete packaging. But I was looking to install it in easier way. so I tried:
Java iPhone


peetacheeta
March 12, 2009: 12:16 am

there is no java section in Cydia
can someone please explain??


C DANWER
February 23, 2009: 7:01 pm

Hi!
Tried it with jar-file… How is it possible to use a jar-archive on iphone?


Michael Zick Doherty
December 2, 2008: 9:11 pm

Kind of unclear on this section:

First install Java on iPhone following instructions in the section above before reading this.

You can upload Java files to iPhone using iPhone Browser.

Where do you upload??

Run Terminal (installed above) and use java (jikes) compiler to compiler your program. For example:
jikes -cp /usr/lib/rt.jar MyFirstJavaProgramForIPhone.java

do you need a directory path before java file?

You can run the class file as usual:
java MyFirstJavaProgramForIPhone

is this also from the terminal??

November 16, 2008: 9:13 am

[...] I have provided two ways how Java developers can install, compile and run iPhone applications on Java. Today I will present a third [...]

July 30, 2008: 3:24 pm

[...] encryption isn’t available to make my messages super-secret and encoded, there are ways around this, and here’s one of a growing number of apps you can use to do that (though, [...]

June 14, 2008: 4:03 am

[...] How To install, Compile, Run Java On iPhone Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages. [...]

June 12, 2008: 3:03 pm

[...] Taragana’s Blog [...]

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :