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
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 🙂