Skip to main content

First steps with iPhone and Java...

Posted by brunogh on May 25, 2008 at 9:49 PM PDT

When I was at JavaOne, I sold my soul to devil: I bought an iPhone. Here in Brazil, there is no iPhone being officially selled yet. Let's start having fun and playing with Java on it:

  1. Unlock your iPhone. Babies can do that before they say mama. More information at Zibri's Blog.
  2. Make it useful: Install Cydia (front-end for Debian APT) to substitute default Installer application. In Installer, go to the Source option, click Edit, Add, Done and then Refresh. Then go to Install option, search for Cydia Installer and install it.
  3. After that, open Cydia and search for the word Java, there are a few stuff part of the iPhone/Java package available in Development menu. You are able to make graphical applications using the UI Framework, which is possible due to JocStrap, a Java/Objective-C bridge. Install iPhone/Java that will bring the necessary stuff (JamVM, etc) for this simple demo. Also, later try to install Jikes, a compiler for version 1.4 and fastjar, an alternative for running jars, because I could not test them yet.

PS: Install OpenSSH in your iPhone and then connect your laptop on its server. Also, install Boss Prefs to be able turn SSH on/off. Finally, do not forget to change you root password using passwd, default password is alpine. I have created a simple Hello World app into NetBeans. Then I have compiled it, tranfered to iPhone and runned (via SSH). Code:

 public class Main {     public static void main(String[] args) {         System.out.println("Hello World... in Java");     } } 

Screenshot: java_iphone.png Community will bring ME world into iPhone as well. The answer for this is phoneME Advanced. Keep and eye and join the mailing lists! As you can see, there are some very nice projects going on! Have a nice and funny week! Bruno Ghisi

Related Topics >>


Having devices run apps not

Having devices run apps not approved by a company is called Jailbreaking. Though it is currently legal in the United States, company like Apple did not want to allow this. The Register made reports on the patent apple seeks that could be “covering an elaborate series of measures.” This will make sure to “protect iPhone owners from thieves” or anybody else a user wants from their iPhone. The patent is called "Systems and Methods for Identifying Unauthorized Users of an Electronic Device," and will make sure a user’s iPhone gets locked down supposedly with jailbreaking exploits.

Hello nicotejera ! Not sure that this vm is full compatible, probably it has just basic java stuff. I am sorry but I do not know about its current status.Thanks, Bruno

To try full Java 1.5

To try full Java 1.5 development on iPhone (without having to unlock it ;)), you can also use iSpectrum from flexycore. ( ) It compiles your Java apps to native code for iPhone with ability to deploy it on the appstore :) Plus, It's free for open source projects.

Hi Bruno, I had success creating a command line app on the iPhone. However, I tried creating a very basic graphic app, using the as a template but it's not working. I copied the entire folder, created a folder with the exact same files. Copied it to the phone, it appears on the springboard but when I run it, it starts and closes immediately. Any ideas? Thanks, Nick

Cool! I was thinking selling my soul too and this post definitely gave me more reasons. Piracucada!

I hope i am wrong...

brunosm -> Actually I do not see future in something that uses a very restrictive business model, like iPhone. I do not like the idea about a company trying to control everything they do. But let's see what happens, they have already gave the SDK, let's wait the next movements... :) Thanks, Bruno

I am not a lawyer, but probably it is not. I think I will have to sell my shoes or my iPhone if I got in trouble! But, actually, who cares about a poor programmer trying to have fun?! :)

"Unlock your iPhone" !? Is this even legal? Regards, Horia

Hello José, off course I remember you! I did not have time to go deeper with iPhone and Java yet, but I will try more things as soon as I can. I took a look in a simple Java application for managing contacts that uses the UI Framework available, but no Swing. Cheers, Bruno

Hello Bruno, We meet at JavaUniversity JavaFX course; You guys did a really cool demo of Bluetooth controling the Tetris application on JavaFX. I want to buy an Iphone but haven't bothered yet because the lack of official Java support Did you guys tried to compile and run a basic Swing app on the Iphone? Looks like a lot of hacking is needed bu on the other hand sounds fun too! Regards, José

Well...Since There is not much "passion" between Apple and Java...I would spend my time -i do- learning the Objetive-C language or makin web applications for java than just playing with a JAvaME on the display...I dont see much future for the Java on the iphone. You cannot play "against" the hardware and software provider...Except if you play the "hacker" game