- iPhoneRoot.com - https://iphoneroot.com -

Tutorial: compile and run Java application on the IPhone

Posted By admin On June 9, 2008 @ 12:53 pm In All,Java,Java applications,Software,Tutorial | Comments Disabled

Run

This is a tutorial, that shows step by step how to use installed Java on the IPhone. Just in case you do not have Java installed on your IPhone there is a tutorial [1] how to do it.

What we need is a working jailbraked [2] IPhone with Java Installed [1]. I used latest firmware 1.1.4, unlocked, jailbreaked and customized by winpwn [3].

Step 1: Create simple Java application, compile and run.

  1. Create file Java4IPhone.java and put simple Java hello-world code there. I used the following code:Create Java hello-world [4]
  2. Upload to IPhone. I used /tmp directory. For uploading I used IPhone Browser [5].
  3. Run Terminal.
  4. Use command java -fullversion or jamvm -fullversion to see if java is avaliable.
  5. Use command jikes to invoke java compiler.
  6. Go to /tmp directory, using command cd /tmp
  7. Compile. We need to specify classpath to basic java packages. If we do not do that, jikes will produce an error (see screenshot). So use the following command: jikes Java4IPhone.java -cp /usr/lib/rt.jar
  8. After compiling Java4IPhone.class file should appear in the same directory. To run use command java Java4IPhone
  9. Take a look at the screenshots. Hopefully you'll have something similar.

Upload Java application to IPhone [6]

Check Java and Jikes [7] Compile using Jikes [8] Run [9]

 

Upload Java application to IPhone [10]

Step 2: Have fun!


Comments Disabled (Open | Close)

Comments Disabled To "Tutorial: compile and run Java application on the IPhone"

#1 Comment By neufuture On December 9, 2008 @ 8:14 pm

how would you compile using other packages? I'm trying to compile processing, so I need to use the "core.jar"

Callum Reply:

Jikes file.java -cp core.jar
Not sure if that's right, give it a go.

#2 Comment By WithRat On June 24, 2009 @ 11:28 am

how can i compile java UI Applications with jikes?
And where can i get documents of the lib jocstrap.jar?
Thanks!

#3 Comment By WithRat On June 24, 2009 @ 11:36 am

I got these when i tried to compile file JavaSysInfo.java:
E:\javapro>javac JavaSysInfo.java
JavaSysInfo.java:31: can not file symbol
symbol: method fullScreenApplicationContentRect()
location: class obc.UIHardware
CGRect rect = UIHardware.fullScreenApplicationContentRect();
^
JavaSysInfo.java:34: can not find symbol
symbol: method defaultSize()
location: class obc.UINavigationBar
CGSize sizenavbar = UINavigationBar.defaultSize();
^
2 errors

Is it that the jocstrap(jocstrap_1.0.2549-8_iphoneos-arm.deb) I got does not fit the source files?

#4 Comment By Ruben On January 17, 2010 @ 10:22 pm

I hope you can help me, well i´ve got every think installed and running but points 7 & 8 are no too clear for my, my file is a .jar one, so i shud´nt compile it, do i? i have tried and nothing, also ia tried to run it by java (filename) but thrn again nothing, im on a 3.1.2 jailbreak os, help me pleas i just want tu run java apps on my Iphone

soulaway Reply:

Just try to change current video settings on your device before you do catch such JavaSysInfo.java:31: can not file symbol.

#5 Comment By Ruben On January 18, 2010 @ 12:18 am

ok, i did it, ;) but... a igot an other prob, when i exec the file becomes a Main-Class on Manifest error, it is a app for a symbian mobile, so, How can i fix this, does anybody knows it? help my pls

#6 Comment By meelooz On February 19, 2010 @ 10:55 am

argh, when will Apple decide to finally accept Java, so we won't have to use these kind of complicated (and borderline) techniques :( ?

Anyway, to compile and run Java application (with UI, WithRat ;) ) on iPhone, I've tried something called iSpectrum.

It complies with the iPhone SDK agreement, since you no longer need to install a JVM, but compiles your Java app to native code. So there is no need to jailbreak your phone :) .
And you develop in Eclipse, with a plugin of their own, and you can even debug your code right from Eclipse Java editor!

Plus, this is free for open source projects ;) .

Check it out at [11]

#7 Comment By Margarett On November 24, 2010 @ 4:36 pm

I just can't understand, will this iSpectrum enable opera mini on iphone which is a java application??

admin Reply:

this will not make java apps work. as for opera mini, there is opera mini app for iphone

#8 Comment By rami On July 7, 2011 @ 11:41 pm

hello...
how can i run - MRemote.jar ?
when i open the MRemote.jar with winrar ,it is include this files = a.class,b.class,c.class,d.class,e.class,MRemote.class,MRemote.png and folder META-INF and MANIFEST.MF .

how can i run - MRemote.jar ?

thanks...

admin Reply:

java -jar?

mike Reply:

Hello, I have the same problem. I have a .jar file that was transferred on the jail break iPhone and now i'm trying to install using terminal and when I use the code

"jikes blooover2.jar -cp /usr/lib/rt.jar" it says "the input file "blooover2.jar" does not have the .java extension

admin Reply:

jikes is a compiler, not the runtime. since you have jar file, it is already compiled, you need to run it with java -jar.

#9 Comment By Ryuk On October 24, 2017 @ 6:47 pm

Hello!

Can you do this procedure with a un-jailbraked iPhone??

admin Reply:

Unfortunately, no.


Article printed from iPhoneRoot.com: https://iphoneroot.com

URL to article: https://iphoneroot.com/tutorial-compile-and-run-java-application-on-the-iphone/

URLs in this post:

[1] tutorial: http://iPhoneRoot.com/tutorial-install-java-on-the-iphone/

[2] jailbraked: http://iphone.unlock.no/

[3] winpwn: http://winpwn.com/

[4] Image: http://iPhoneRoot.com/wp-content/uploads/2008/06/step3_0.jpg

[5] IPhone Browser: http://code.google.com/p/iphonebrowser/

[6] Image: http://iPhoneRoot.com/wp-content/uploads/2008/06/step3_01.jpg

[7] Image: http://iPhoneRoot.com/wp-content/uploads/2008/06/step3_1.jpg

[8] Image: http://iPhoneRoot.com/wp-content/uploads/2008/06/step3_3.jpg

[9] Image: http://iPhoneRoot.com/wp-content/uploads/2008/06/step3_4.jpg

[10] Image: http://iPhoneRoot.com/wp-content/uploads/2008/06/step3_5.jpg

[11] : http://www.flexycore.com

Copyright © 2008-2015 iPhoneRoot.com. All rights reserved.