For a course i’m taking this year for my degree we’re, building J2ME MIDlet applications. JAVA isn’t really my thing but I suppose it can only make me enjoy those chances when I get to use Ruby a lot more.
Took me a good bit of searching around to get everything working so hopefully this will save you some trouble.
Pre-requisites
- You’re using Mac OSX 10.4.x
- You’re at Java 1.5 (comes with Mac OSX)
- You’ve installed the Mac OSX developer tools (especially Xcode)
Installation
Okay we’re going to download and install a couple of things to get up and running.
- Install Ant
- Install the emulator and sdk
- Setup Xcode
- Test it out!
Install Ant
Download the latest source file from the Ant site. Fire open your favorite terminal application and cd to the extracted directory. Now simply run the build script, you’ll have to choose somewhere to install Ant, I thought /Library/Ant was a good one.
sh build.sh -Ddist.dir=/Library/Ant dist
That should be it good to go, you may have to create some symlinks from /usr/local/bin let me know if this doesn’t work for you.
Install the emulator and sdk
Download the sdk from Mpowerplayer here and extract to /Developer/Java/
Setup Xcode
Haiku Software produced a great template for use with Xcode. Download it here and copy it into
/Library/Application%20Support/Apple/Developer%20Tools/Project%20Templates/Java/
I have previously gotten errors when compiling with the default template. To fix this, before you copy the template, open up the build.xml file and change the following
<property name="java.classes.jar" value="/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar" />
to
<property name="java.classes.jar" value="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar" />
Test it out!
Open Xcode and choose New Project, scroll down to the Java section and choose Ant-based MIDlet Jar. When you hit build and go it should build the jar file and open up in the emulator. Hurray!