Apr
13
2006

J2ME Development on NetBeans 5.0 in Mac OS X

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 :)

Written by Florian Beer in: development, mac
rel-tag , , ,

45 Comments »

  • links from Technorati15 years experience in Java? teleportation? Gosh. Are these people that clueless? Then again, my profile page probably makes my work seem too boring - maybe I ought to mention the surreal bits as well… Florian hasan excellent piece on setting up a MIDP/J2ME environment in Mac OS X (a long neglected pursuit of mine). Now all I need is the time to do the same. Thomas Fuchs has published his slides from Canada on Rails, which I found very entertaining indeed. In fact, they nearly

    Pingback | 19. April, 2006
  • hi, florian.
    thanx for this tutorial, i got it from rui’s site, the.taoofmac.com.
    excellent resource, although I figured out how to do the same using eclipse and eclipseME.
    it’s been a painful process, which eventually led me to move to Windows for just j2me development (eclipse ain’t that smooth on mac).
    I’ll definitely try this and see if I can get better results using NetBeans.
    thank you for supporting the mac community on this.

    ciao.ubi

    Comment | 19. April, 2006
  • Hi Florian, nice summarization.
    Mac OS isn’t supported platform yet. Main reason is - we don’t expect that too many people are using it for j2me development. Convince us and vote for this issue ;)

    Comment | 21. April, 2006
  • Hi Florian,

    Thanks for the summary here, this looks really promising! I seem to have all the bits I need, but something goes wrong when I try to build, the preverifying step craps out as follows:

    Preverifying 3 file(s) into /Users/jnutting/play/FirstMidpGame_mark2/build/preverified directory.
    /Users/jnutting/play/FirstMidpGame_mark2/
    nbproject/build-impl.xml:269: java.io.IOException: “/Users/jnutting/Library/mpp-sdk/osx/preverify/preverify”: not found
    BUILD FAILED (total time: 0 seconds)

    I’ve checked and double-checked the path to the preverify command (and yes, it is executable, I can run it manually etc). I’ve even moved the mpp-sdk location to a completely different location, recreated the config in NetBeans, and I still keep getting this error! I’ve also tried messing with the double-quotes in the config strings (since they seem to be turned into “smart quotes” when I copy from your page), but that made no difference either.

    Any ideas?

    Comment | 21. April, 2006
  • Problem solved…. it was indeed the “smart quotes” that came along in the copy/paste. This was exacerbated by the fact that even though NetBeans lets you edit the Preverify Command string in the Java Platform Manager window, it doesn’t actually save the changes you make there! After I realized that, I deleted and recreated the mpowerplayer platform again, and now it compiles fine.

    (To save others from this error, you may want to modify the source of this page a bit, changing the #8220 and #8221 elements to quot on the line in question so that it can be copy/pasted correctly)

    Thanks again for the excellent step-by-step!

    Comment | 21. April, 2006
  • @Lukas
    I voted ;) (I’ll spread the word so others do it as well)
    I think you should definitely start thinking about OS X as supported platform in the future. At least at my university there seems to be a drift to switch to OS X and J2ME development is part of our education. So at least in Austria there will be a couple of J2ME developers in the coming years ;)

    @Jack
    Thanks for the feedback!
    I modified the source as you suggested, hopefully it copies right now (got no time to test it at the moment).

    Comment | 21. April, 2006
  • links from Technoratidoing some C and Symbian (the thing I hate the most is have to wait for people to develop for me, when I know I could do it.) My extensive google searches and some tips from Rui Carmo’s wiki got me a small collection of useful links. J2ME on macFlorian Beer wrote a tutorial explaining how to use it with NetBeans (using the Linux mobility pack and tweaking it on mac). MobUser writes about how to configure Eclipse to use MPowerPlayer or ME4SE. J2ME Polish

    Pingback | 25. April, 2006
  • [...] article [...]

    Pingback | 26. April, 2006
  • Kramer auto Pingback[...] J2ME Development on NetBeans 5.0 in Mac OS X Filed under OSX, j2me, java, mac, mobile, netbeans by deliciousosx [...]

    Pingback | 30. April, 2006
  • Colin

    Hi,

    thanks for the HOWTO.

    Just wanted to point out that the quotes problem for the Preverify Command in step 9 above still exists.

    Also, trivially, the path in step 13 is wrong. It should be /System/Library/Frameworks/JavaVM.framework/Classes/

    And finally, in step 14, cldcapi10.jar and midpapi20.jar were NOT in the Mobility pack downloaded in step 2. (???) (but were in the tarfile linked in step 14).

    Thanks again, and OF COURSE Mac OS X should be a supported platform! :-)

    Comment | 3. May, 2006
  • Colin

    Sorry, I also wanted to ask:

    Are there any files that could be added to the Sources and Javadoc fields in the next panel?

    Comment | 3. May, 2006
  • Thank you for your feedback Colin!

    I corrected the error in step 13.

    The quotes in step 9 are still an issue I know, but this blog software somehow doesn’t want me to change it. I had several issues with code listings in the past, so if anybody has some suggestions to improve code listings in wordpress just let me know!

    The cldcapi10.jar and midpapi20.jar ARE in the Mobility Pack, although somewhat hidden. That’s why I offered the files on my server for ease of use.
    They are in mobility7.2/emulators/wtk22_linux.zip which you have to decompress and there you’ll find them in wtk22_linux/emulator/wtk22/lib/. So now you see why my way was much easier for this HowTo ;)

    As for your second question: I don’t exactly know which files you want to put in there. Could you elaborate on that?

    Comment | 3. May, 2006
  • Colin

    OK, thought the APIs might be hidden :-)

    As to Sources and Javadoc - I don’t know. That’s the question. I assume this is javadoc etc to enable code completion and hints etc (in the editor) when using MIDP and CLDC ?

    Comment | 4. May, 2006
  • Hi, im asleep for three days trying to put my brand new mac mini to work the same way my G4 does.

    Well, all mi midlets refuse to preverify, after giving up with xcode and mpowerplayer i try your tutorial, well, mi preverify still fails.

    If i change my jvm to 1.4.2 the preverify doesn´t fail, BUT the midlets didn’t work on phone but it does in emulator.

    The almost famous error is :

    Error preverifying class java.lang.Class
    VERIFIER ERROR java/lang/Class.newInstance0()Ljava/lang/Object;:
    Illegal type in constant pool
    /Users/eduardo/MobileApplication/nbproject/build-impl.xml:269: Preverification failed with error code 1.
    BUILD FAILED (total time: 3 seconds)

    Anyone can help me ?

    ppppleaseeee …..

    Comment | 11. May, 2006
  • Jan

    Same error here :(

    Comment | 28. May, 2006
  • [...] My favourite Java IDE, Netbeans, now has this great Mobility Pack, which gets you started on mobile applications quite easily. You even get a nice graphical editor for the UI. Even better, I found directions on how to set the whole thing up for OS X, so I can now hack away on my new PowerBook whenever I feel like it. Nice. [...]

    Pingback | 30. May, 2006
  • links from Technoratiこんな

    Pingback | 4. June, 2006
  • I’ve got the “Preverification failed with error code 1. error as well”. It would be great if someone would know how to fix it. Otherwise, thanks for the great tutorial!

    Cheers, Filip

    Comment | 24. June, 2006
  • TK

    Hello!
    I’m Japanese Mac hobbyist.
    I made a Japanese tutorial by referring to this blog.

    Thank you very much. ALL

    And, I will make a Mobile Application .

    Comment | 26. June, 2006
  • [...] Pel que veig, apart de tenir instalat el NetBeans IDE, necesito instalar el NetBeans Mobility Pack 5.0 i la cosa no pinta gaire bé, ja que no veig que estigui disponible per a Mac. He trobat informació de com instalar-ho, aquí i aquí. [...]

    Pingback | 30. June, 2006
  • links from Technoration a Mac yet? Does it run on a Mac yet?…and the answer has been “no”. Running it across the network via X11 or similar, or running inside a Windows emulator, isn’t ideal so I’ve more-or-less avoided NetBeans. However, blogs from Lukas Hasik and Florian Beer pointed out that you can hack the mobility downloads to make it run on Mac OS X, so I took the plunge with it under NetBeans 5.5 beta with the enterprise pack. And sure, it works: [IMG Screen shot of NetBeans running on the Mac with the Mobility

    Pingback | 27. July, 2006
  • Kramer auto Pingback[...] J2ME on mac Florian Beer wrote a tutorial explaining how to use it with NetBeans (using the Linux mobility pack and tweaking it on mac). [...]

    Pingback | 29. July, 2006
  • Tim

    The preverifier error occurs if you’re using Java 1.5. I used the 1.4.2 version (stored in/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/) and the preverifier seems to work.

    Comment | 8. August, 2006
  • Hovl

    Is it possible to install Mobility Pack on NetBeans 5.5?

    Comment | 9. August, 2006
  • @ HOWL - the Mobility Pack 5.5 Beta2 is available for download on the same page as NetBeans 5.5 Beta2.

    http://www.netbeans.info/downloads/download.php?type=5.5b2

    Comment | 24. August, 2006
  • Hi all Mac users,
    there is the mobility pack available in zip distribution. You don’t have to use the zipped build from linux anymore. The zip is for NetBeans 6.0, so now it’s in development stage - can be unstable.

    There will be a Milestones builds available together with NetBeans. I hope that you’ll enjoy it.
    http://blogs.sun.com/lukas/entry/zip_distribution_of_mobility_pack

    Comment | 1. September, 2006
  • emanus

    Is it possible to install MPP on NetBeans 5.5 for windows?

    Comment | 1. September, 2006
  • Kramer auto Pingback[...] Aqu he encontrado un blog que explica cmo hacerlo sacndolo de la versin Linux. ——————– iBook G3 900 Mhz - 12" - Combo 640 Mb RAM - Airport—-Power Mac G5 2×2 - 1 Gb Ram - Ati 9800Apple Studio Display 17" - Motu Audiophile USB—-Power Mac G4 - 400 Mhz - 640 Mb RAMHD FW Lacie 80 GB - OS 9.2 [...]

    Pingback | 17. September, 2006
  • Kramer auto Pingback[...] document.writeln(’Reply | ‘); Reply to Author if( Nabble.user == 70244 ) { document.writeln(’| Delete’); } | View Threaded | Link to this Message Michael, there are available zip distributions for Netbeans Mobility Pack 6.0 These build are only dailies therefore it’s not final product quality but it will improve. If you want a final product quality you’ll have to use the trick from the post that Anatole pointed to. I’m posting some links how to start working with these daily builds. There is even a little bit more updated document how to start working with Mobility Pack on Mac. http://blogs.sun.com/lukas/entry/zip_distribution_of_mobility_pack http://wiki.netbeans.info/wiki/view/MobilityFromZipToNB http://www.netbeans.info/downloads/download.php?a=n&p=1&rv=6.0&bt=4&step=2 http://blog.no-panic.at/2006/04/13/j2me-development-on-netbeans-50-in-mac-os-x/ Good Luck Lukas Anatole Wilson wrote: > Michael, > > You’re not the only one who has asked about this. The main problem is > the lack of emulators that work in a Mac environment. I’m forwarding > this to the users@… mailing list so they can see > this request and perhaps make some recommendations for you. > > Although we don’t officially support MacOS X, there actually is a way > to install the NetBeans Mobility Pack CLDC on the Mac. > Please take a look at Lukas Hasik’s blog, > http://blogs.sun.com/roller/page/lukas?entry=mobility_pack_on_mac > and let me know if you have any questions. > I’m not sure if it would work, though, for the CDC Pack. The Sun Java > Wireless Toolkit for CDC we include does not support Mac OSX. > > Thanks for writing, > > Anatole Wilson > Sr Information Designer > NetBeans Mobility Packs > > delgaudio@… wrote: > >> I’de love to see the Mobility Pack for OSX! Unless I’m missing >> somethign? Great product. >> >> >> -Michael >> >> —- >> Submitted via the contact form at: >> http://netbeans.info/contact_form_tool/index.php >> Referer page: http://www.netbeans.org/kb/55/mobilitycdc.html >> >>   >> > > ——————————————————————— > To unsubscribe, e-mail: users-unsubscribe@… > For additional commands, e-mail: users-help@… > [lukas.hasik.vcf]begin:vcard fn:Lukas Hasik n:Hasik;Lukas org:Sun Microsystems;Mobility Pack QE email;internet:lukas.hasik@… x-mozilla-html:TRUE url:http://blogs.sun.com/lukas version:2.1 end:vcard ——————————————————————— To unsubscribe, e-mail: users-unsubscribe@… For additional commands, e-mail: users-help@… if (Nabble.searchterms != null && Nabble.searchterms.length > 0) { Nabble.hilt(Nabble.searchterms, Nabble.get(”nabble.msgtxt6679367″)); } if( Nabble.prev ) document.writeln(’« ‘+Nabble.prev+”); Nabble.copyright = “© 2005-2006 Nabble, Inc.”; [...]

    Pingback | 19. October, 2006
  • ggd

    Hy,

    I finally got the NetBeans helloWorld working on my (french) iBook with NetBeans (and on my se w810)!

    I had to make the 2 changes precedently mentioned :
    •“smart quotes” to standard quotes on step 9
    •System/Library/Frameworks/JavaVM.framework/Classes/ to /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes on step 13

    thank you so much for making this so clear!

    by the way, I still have a non fatal error (but, hey, it works!) :

    CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0×44f), port = 0×10403, name = ‘java.ServiceProvider’
    See /usr/include/servers/bootstrap_defs.h for the error codes.

    java[978] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)

    I’ve looked at the bootstrap_defs.h file but that doesn’t talk much to me…

    Thanks again, and sure I’ve voted the issue!

    Comment | 22. October, 2006
  • [...] No Native Installer for the Mobility Pack, but… There is a solution detailed here. [...]

    Pingback | 8. January, 2007
  • Prasad

    Thank your very much for your information, this is really useful to develop J2ME stuff on Mac OS X.

    Comment | 9. January, 2007
  • Ryan

    I’ve been trying to get this installed under Netbeans 5.5, and it will not recognize the mpowerplayer as a platform. In 5.5, you are no longer allowed to manually enter the platform home. Instead, you have to browse to it and select it. In my version, there is no way to select the mpp-sdk folder as a platform folder. Did I miss something? I changed the permissions to allow the preverify to execute, and have tested this in the terminal.

    Comment | 29. January, 2007
  • @Ryan:
    Since my work doesn’t require J2ME at the moment I haven’t updated to Netbeans 5.5 yet. So I can’t really figure out what the problem is there. I’d be glad if anyone could offer an update to this HowTo for the most recent Netbeans version.

    Comment | 29. January, 2007
  • hoppelmoppel

    Yeah … got the same problem here. Netbeans 5.5 doesn’t recognize the mobility pack …

    Any ideas?

    Comment | 10. February, 2007
  • Found a Solution here: http://wiki.netbeans.org/wiki/view/MobilityFromZipToNB

    u only need to edit in de netbeans installation folder the file etc/netbeans.clusters und add cdc2 (or whatever).

    Now u can use and see it in the project profiler.

    Comment | 10. February, 2007
  • Kramer auto Pingback[...] du hast recht, bezieht sich aber "nur" auf CDC fr MLDP habe ich gerade das hier gefunden: http://www.mpowerplayer.com/products-sdk.php edit: noch einer (Java 2 ME mit Netbeans auf Mac OS X): http://blog.no-panic.at/2006/04/13/j…0-in-mac-os-x/ Gendert von nielsb (Gestern um 16:03 Uhr). [...]

    Pingback | 22. February, 2007
  • Kramer auto Pingback[...] Cita Ciao a tutti, avrei un problema con il mobility pack su mac, in particolare su netbeans…ho letto un topic al riguardo, che per non presenta il mio problema, che il seguente: ho seguito le seguenti guide, http://blog.no-panic.at/2006/04/13/j…0-in-mac-os-x/ e http://blogs.sun.com/lukas/entry/mobility_pack_on_mac, per quando arrivo al momento di addare la platform, non mi compare la schermata di spunta in cui scegliere java micro edition platform, ma una schermata in cui mi dice di caricare la cartella che contiene la platform, non so se mi sono spiegato; in pratica sembrerebbe che, nonostante abbia copiato la cartella mobility in netbeans, questa non viene vista,,premetto che ho provato prima con netb 5.5, poi con il 5.5 e il mobility pack 7.3, versioni diverse da quelle indicate in guida ma a rigor di logica il trattamento dovrebbe essere lo stesso. Per chi mi indica la guida di loreto parisi ho letto sia quella di xcode qua sul forum, sia quella sul suo blog (che uguale a quelle segnalate sopra), lo dico cos per risparmiare tempo a chi veniva in mente di farlo e per dire che sono due giorni che ci sto sopra..premetto che se qualcuno mi aiuta a venirne fuori con netbeans mi fa un grandissimo piacere piuttosto che xcode, perch un ambiente molto pi familiare e che aiuta moltissimo in caso di grafica. ciao a tutti [...]

    Pingback | 25. February, 2007
  • I’m using the modified instructions here to get the mobility pack working in NB6 M7.

    I still get the preverify error:
    Preverifying 1 file(s) into /Users/adrian/Projects/NB6/MobileApplication1/build/preverified directory.
    Error preverifying class java.lang.Class
    VERIFIER ERROR java/lang/Class.newInstance0()Ljava/lang/Object;:
    Illegal type in constant pool
    /Users/adrian/Projects/NB6/MobileApplication1/nbproject/build-impl.xml:416: Preverification failed with error code 1.

    I’ve added the 1.4.2 version of classes.jar where necessary.

    I’ve even wrapped the preverify script with:
    #!/bin/sh
    export PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/bin/:$PATH
    /Users/adrian/opt/java/mpp-sdk/osx/preverify/preverify $*

    I know this is a long thread now, but any ideas?
    Thx
    Adrian

    Comment | 28. February, 2007
  • Thank you to all of you for the valuable Tips. I also got it working under Apples xCode mPowerPlayer even comes with a MIDP Code Template for xCode. The whole build process works fine via an ant script.

    The most important step is to call everything with the java 1.4.2 compiler. javac version 1.5 DOES NOT WORK for J2ME Development.

    Comment | 6. April, 2007
  • Sanjer

    I have got it working on Mac with XCode and MPowerPlayer.Compiles and and runs good on Emulator. But when I transfer the .jar to the actual device I get
    “java/lang/ClassFormatError: Bad version information” error message.

    I have specified the required attributes(-1,Name,Vendor,Version,Configuration,Profile) in the manifest.

    Any idea folks ? Thanks in advance.

    Comment | 26. May, 2007
  • Kramer auto Pingback[...] Quote Ciao a tutti, io devo installare il Mobility Pack del NetBeans ma non esiste una versione x i nostri mac!!!…c’e’ pero’ un altro metodo che ho visto al sito http://blog.no-panic.at/2006/04/13/j…0-in-mac-os-x/ ho seguito passo passo tutte le istruzioni e tutto sembrava funzionare ma poi quando faccio il "build" di un file mi appare Preverifying 3 file(s) into /Users/Elisa/test4/build/preverified directory. /Users/Elisa/test4/nbproject/build-impl.xml:269: java.io.IOException: /Applications/mpp-sdk/osx/preverify/preverify: not found BUILD FAILED (total time: 0 seconds) qualcuno ha gia’ installato questo programma e sa come risolvere il mio problema? Grazie! [...]

    Pingback | 21. June, 2007
  • Kramer auto Pingback[...] Well you need a J2ME midp 2.0 SDK to run mobile phone programs/games and it appears that MPowerPlayer is the only or most popular choice. There pages might also be of interest: http://www.urbanhill.net/midp/ http://homepage.mac.com/sroy/midletrunner/ http://mpowers.net/midp-osx/ http://blog.no-panic.at/2006/04/13/j…0-in-mac-os-x/ Last edited by melon : 06-20-2007 at 01:56 PM. [...]

    Pingback | 29. June, 2007
  • Kramer auto Pingback[...] and launch the emulator. Using NetBeans Mobility Pack I haven’t tried this one myself. Here is a small HOWTO on how to accomplish it. References Doing Midlets On Osx using antennae and wtk [...]

    Pingback | 2. October, 2008
  • [...] haven’t tried this one myself. Here is a small HOWTO on how to accomplish [...]

    Pingback | 18. June, 2009

RSS feed for comments on this post.
TrackBack URL.

Leave a comment