How to Install, Compile, Run Java Apps on iPhone

So what if Apple will not allow Java to come on iPhone? We have a workaround living for a year now. But not many people know about it, and it’s scattered. But I`ll make it easy for you.

Disclaimer- It’s illegal to jailbreak and blah blah, do it at you own risk.

Here is an Easy Tutorial -

Pre-requistes – You iPhone should be Jailbroken and “terminal” installed. You can follow the guide here.

Step 1. Goto Cydia and search for “Java” and install it. The package is Approx. 12mb in size and installs Classpath, iPhone/Java, JamVM, Java SQLite, JocStap, etc. In addition few sample applications with source are installed (HelloJava, HelloScript). Then search for “Jikes“, the compiler or javac equivalent, and install it.

Step 2. Now it’s time to write some code. There are two ways either create .java file with your favorite editor  and transfer to iPhone or directly use vi editor on iPhone (later would be very cumbersome to do.). If you make first choice, use WinSCP or any other SFTP client to transfer file to iPhone. You an use any directory. I`ll use /tmp for my example.

Step 3. If you are developer, you know the next step. Open “Terminal” and type in “su” enter, followed by root password i.e. “alpine”. Then validate java installation “java -version”. It would display “1.5.0 “and the build info, compiled with GCC on Apple bla bla. and also type “jikes” and test. So we are ready. to compile the code. (root permissions are required to create .class file as a result of compilation)

Step 4. Navigate to location where you placed your java source file. “cd /tmp” and then compile the file using command

“jikes Taranfx.java -cp /usr/lib/rt.jar”

You will have to mention the classpath during compile, else it will not work.

Then run it using standard command

java Taranfx

And you get the output :)

VN:F [1.9.22_1171]
Rating: 6.1/10 (8 votes cast)
VN:F [1.9.22_1171]
Rating: -2 (from 2 votes)
How to Install, Compile, Run Java Apps on iPhone, 6.1 out of 10 based on 8 ratings

Related Posts

Bookmark and Promote!

  • Lexaniji

    Cool man thanks :D
    luv it :D

    again thanks m8

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Casper Bang

    Or use Mono, you won’t have to jailbreak your phone: http://www.mono-project.com/MonoTouch

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Guest

    any1 tried that?
    because it isnt working here.
    problem: java samples (HelloJava, HelloScript) not working – maybe of new FW verision (3.0.1).

    need help, plz

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Guest

    java tool not working.
    maybe its the new iphone fw (3.0.1) or anything else.
    i cant even start those 2 samples (HelloJava, HelloScript).

    need help, plz.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • guest

    I'm running version 3.0.1 and it's working fine on my phone except for the two apps installed (HelloJava and HelloScript) do nothing. Follow each step in this tutorial and you can run Java programs on your phone!

    One thing I will say, the Scanner.class is not in the rt.jar file. I don't know why they didn't include it but if you want to get input from the user than here's an alternative:

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    Hopefully they include the Scanner.class in a future update to this.

    Happy coding!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • SkyMan

      Want to develop in Java for iPhone on Eclipse without jailbraking your iPhone ? iSpectrum is for you, and it's free for open source! check http://www.flexycore.com. Enjoy:)

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • SkyMan

    Want to develop in Java for iPhone on Eclipse without jailbraking your iPhone ? iSpectrum is for you, and it's free for open source! check http://www.flexycore.com. Enjoy:)

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Blake

    have a jailbroken Iphone with 3.1.2 firmware. looking to run a .jar file on the iphone. have already installed java and jikes with cydia. above example says to run file with .java extension. I have file with .jar extension that is supposed to automatically unpack itself when put on java enabled phone and run. can I do this on my phone. if so how please.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • John

      how come java isn't in cydia Im running on a 3.1.2 firmware

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Montana

    No it's not illegal to jailbreak. Apple just thinks it is. What it does do is void your warranty.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • vahnx

    It's nice seeing Java on the iPod Touch.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Dgroyer

    Please email me the helloworld script to dgroyer@gmail.com.. Thank you very much!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Tol Van D1973

    L.s,

    it look great, does it work on ipad ?
    can give me some direction ?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Chaitanyarebbana

    hi this is very nice. can i install java on ipad in the same way?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • http://www.taranfx.com Taranfx

    yes

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • est399

    And what should I do if I want to launch a program in .jar?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Benimblejack404

    I get a semantic error when i use a Scanner on the iPod, but the file works fine in jcreator or jgrasp on a windows machine. Do you know what might be causing this?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Singhania Bs

      even i have the same problem… 

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Anonymous

    And what should I do if I want to launch a .jar program after all needed app are installed i.e. Cydia, Java, Terminal etc?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • needtoknow

      Please let us know if you receive an answer to this question.

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • http://twitter.com/federico9292 Federico ⚡

    mother of god what repository is? there’s no Java tweak in default repos….!!!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Anonojohno

      set yourself as develepor in manage in the top left corner

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
© 2014 Geeknizer. All rights reserved. XHTML / CSS Valid.
Designed by taranfx.