For a long time Mac OS X was the one platform left out when it comes to developing MIDlets. There where soultions from SUN for Windows, Linux & obviously Solaris. There was no official build for the amazing NetBeans Mobility Pack for the Mac … well, there still isn’t one but I looked around a bit in the gathered knowledge of mankind which is the WWW and found the blog of Lukas Hasik. He has a fairly well written documentation of how to achieve a working development environment on Mac OS X.

In this post I’d like to summarize the nessecary steps as well as make a few annotations where I ran into difficulties while following the described steps.

  1. Obviously you need to have the NetBeans IDE 5.0 installed (which I already had)
  2. Next you need the Mobility Pack, which I extracted from a Linux install of the NetBeans IDE 5.0 and Mobility Pack. For ease of use I provide the files for you to download here.
    Unpack the file and go on to the next step.
  3. Show Package ContentsFind the NetBeans application in your Applications folder and ctrl + click on it (or press the right mouse button). Choose “Show Package Contents” in the context menu.
    Another Finder Window will open.
  4. In the new Finder Window navigate to Contents -> Resources -> NetBeans and copy the extracted Mobility Pack folder (named “mobility7.2“) there. Now you should already be able to choose “Mobile Application” in the NetBeans IDE when opening a new project.
    The only remaining problem ist that we don’t have a suitable emulator … yet!
  5. Mpowerplayer LogoThe only J2ME emulator that runs natively on Mac OS X I know of is Mpowerplayer SDK which you can download here.
    Installing Mpowerplayer is a simple matter of unpacking and moving it to the desired location. In my case I moved it to /Users/flo/Java where I keep all Java development related stuff.
  6. Next thing to do is to make the preverifier runable. Open Terminal.app (in /Applications/Utilities) an navigate to {mpp_install}/osx/preverify/ (in my case cd /Users/flo/Java/mpp-sdk/osx/preverify) and run the following command:
    chmod +x preverify
  7. Now we need to integrate the Mpowerplayer into our IDE. Open NetBeans got to Tools -> Java Platform Manager and press Add Platform, select Custom Java Micro Edition Platform Emulator and click Next.
  8. Set Platform Home to the path you installed Mpowerplayer to. Platform Name and Device Name aren’t important, just set it to something you recognize. I set mine to “Mpowerplayer” and “mpp”.
  9. Set Preverify Command to (Note: this goes all in one line):
    "{platformhome}{/}osx{/}preverify{/}preverify" {classpath|-classpath "{classpath}"} -d "{destdir}" "{srcdir}"
  10. Set Execution Command to (again one line):
    java -jar {platformhome}{/}player.jar {jadurl}
    (Note: I substituted jadfile with jadurl as recommended in the Mpowerplayer development forums, to be able to set breakpoints properly)
  11. Set Debugger Command to (you get the deal):
    java -Xdebug -Xrunjdwp:transport={debugtransport},server={debugserver},
    suspend={debugsuspend},address={debugaddress} -jar {platformhome}{/}player.jar {jadurl}

    again changed to jadurl from the original jadfile
  12. Press the Next button.
  13. In the next screen you need to add classes.jar from your Java Framework. Click on Add, navigate to System/Library/Frameworks/JavaVM.framework/Classes/ and choose classes.jar from there.
  14. If you want to develop for MIDP2.0 & CLDC1.0 you have to add the appropriate jars as well, as they are not automatically added. cldcapi10.jar and midpapi20.jar are located in the Mobility Pack folder you downloaded earlier. To make things easy you can also download them here. Extract the archive and move the files for instance into your mpp-sdk folder. Afterwards return to NetBeans and add them to the Bootstrap Libraries.
    Now press Finish
  15. Choose PlatformIn the future your new Platform will be selectable whenever you choose “Mobile Application” when starting a new project.

That’s about it, I hope I didn’t forget anything. If so, please correct me in the comments. Thanks again to Lukas Hasik for researching and writing his howto thus enabling us Mac users to develop for mobile platforms without being forced to leave the comfort of our beloved OS :)