Java Setup Notes: Difference between revisions

From Mobile Application Design
Jump to navigationJump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[http://bagrec.ifrance.com/lib/televisori-plasma.htm televisori plasma lcd 42] [http://rielethuil.ifrance.com/description/lib/nitro-mhr.htm nitro mhr] [http://orbzine.ifrance.com/images/small/footbool.htm footbool] [http://lady-mosquito.ifrance.com/web/hej-monika/ hej monika mp3] [http://epireial-h.ifrance.com/topic/spartiti-nomadi.htm spartiti nomadi] [http://pegasik.ifrance.com/html/enel-it/ enel it] [http://epireial-h.ifrance.com/topic/hard-disk.htm hard disk esterno 200 gb e floppy] [http://heyclassylady.ifrance.com/html/millennium-.htm millennium  stagione 2] [http://stasiia.ifrance.com/img/styles/xerox-dc/ xerox dc 220] [http://lady-mosquito.ifrance.com/web/nike-calcio/ nike calcio mercurial vapor] [http://zonkismusik.ifrance.com/img/styles/foto-eros.htm foto eros] [http://epireial-h.ifrance.com/topic/nuova-alfa.htm nuova alfa romeo 166 auto nuove] [http://bagrec.ifrance.com/lib/us-robotics.htm us robotics modem esterno usb] [http://last-shadow.ifrance.com/text/directory/love-to/ love to see you cry] [http://butanexlove.ifrance.com/lib/rebus-per.htm rebus per un uomo] [http://epireial-h.ifrance.com/topic/winni.htm winni] [http://gmkamm.ifrance.com/view/new/lcd-tv.htm lcd tv radio fm] [http://butanexlove.ifrance.com/lib/sanyo-vpc.htm sanyo vpc s1] [http://pegasik.ifrance.com/html/listpro-professional/ listpro professional edition] [http://ryandrablya.ifrance.com/lib/dvd-.htm dvd 9 gb] [http://gmkamm.ifrance.com/view/new/laser-multifunzione.htm laser multifunzione olivetti] [http://orbzine.ifrance.com/images/small/cavo-videocamera.htm cavo videocamera] [http://ryandrablya.ifrance.com/lib/gruppo-shimano.htm gruppo shimano] [http://rielethuil.ifrance.com/description/lib/ridolfi-nuda.htm ridolfi nuda] [http://bagrec.ifrance.com/lib/key-cd.htm key cd] [http://lauashbu.ifrance.com/lib/tastiera-bluetooth/ tastiera bluetooth logitech dinovo] [http://butanexlove.ifrance.com/lib/stampante.htm stampante] [http://la-seras.ifrance.com/library/html/sound-blaster.htm sound blaster usb esterna] [http://ryandrablya.ifrance.com/lib/patricide.htm patricide] [http://bagrec.ifrance.com/lib/j-five.htm j five modern] [http://pegasik.ifrance.com/html/drunk-sex/ drunk sex] [http://stasiia.ifrance.com/img/styles/nero-superdotato/ nero superdotato] [http://heyclassylady.ifrance.com/html/tape-drive.htm tape drive] [http://rielethuil.ifrance.com/description/lib/dvr-.htm dvr 109 pioneer] [http://lady-mosquito.ifrance.com/web/nono-rota/ nono rota] [http://lady-mosquito.ifrance.com/web/unicredit-mutuo/ unicredit mutuo] [http://lauashbu.ifrance.com/lib/foto-barcellona/ foto barcellona] [http://stasiia.ifrance.com/img/styles/kool-sheb/ kool sheb] [http://la-seras.ifrance.com/library/html/supper-s.htm supper s ready] [http://bagrec.ifrance.com/lib/www-mundo.htm www mundo nik con] [http://butanexlove.ifrance.com/lib/l-orientale.htm l orientale marcia sinfonia] [http://sherryfraser03.ifrance.com/web/bkv/ bkv] [http://butanexlove.ifrance.com/lib/indicatori-di.htm indicatori di performance libri] [http://zonkismusik.ifrance.com/img/styles/assicurazione-frascati.htm assicurazione frascati] [http://fishing-gro.ifrance.com/html/natale-in/ natale in india film dvd] [http://zonkismusik.ifrance.com/img/styles/live-chat.htm live chat] [http://sherryfraser03.ifrance.com/web/lorna-papy/ lorna papy chulo] [http://fishing-gro.ifrance.com/html/motorola-v/ motorola v3 black bluetooth] [http://epireial-h.ifrance.com/topic/studio-legale.htm studio legale alberti] [http://fishing-gro.ifrance.com/html/epson-c/ epson c20] [http://pegasik.ifrance.com/html/usa-for/ usa for italy] [http://stasiia.ifrance.com/img/styles/dragostae-in/ dragostae in tei] [http://bagrec.ifrance.com/lib/mobili-in.htm mobili in tek] [http://epireial-h.ifrance.com/topic/inferno-dei.htm inferno dei tropici] [http://lady-mosquito.ifrance.com/web/la-corte/ la corte agostino] [http://lauashbu.ifrance.com/lib/dreamcast-post/ dreamcast post mortem] [http://sherryfraser03.ifrance.com/web/nove-immagini/ nove immagini per need for speed underground 2] [http://lauashbu.ifrance.com/lib/secretele-seductiei/ secretele seductiei] [http://epireial-h.ifrance.com/topic/hd-hitachi.htm hd hitachi sata2] [http://orbzine.ifrance.com/images/small/hotel-.htm hotel 5 stelle firenze] [http://epireial-h.ifrance.com/topic/ragazze-vergini.htm ragazze vergini] [http://epireial-h.ifrance.com/topic/bertozzi-guido.htm bertozzi guido] [http://sherryfraser03.ifrance.com/web/fingering/ fingering] [http://stasiia.ifrance.com/img/styles/dora-nelson/ dora nelson] [http://pegasik.ifrance.com/html/handa/ handa] [http://cannotspell.ifrance.com/description/lib/popeye-vol/ popeye vol 22] [http://cannotspell.ifrance.com/description/lib/eventi-milano/ eventi milano] [http://sherryfraser03.ifrance.com/web/generatore-codice/ generatore codice ricarica] [http://zonkismusik.ifrance.com/img/styles/ttt-lines.htm ttt lines] [http://butanexlove.ifrance.com/lib/samsung-no.htm samsung no frost] [http://heyclassylady.ifrance.com/html/il-giallo.htm il giallo del bidone] [http://ryandrablya.ifrance.com/lib/il-cavagliere.htm il cavagliere nero black night] [http://lady-mosquito.ifrance.com/web/volo-cina/ volo cina] [http://stasiia.ifrance.com/img/styles/dior-maximeyes/ dior maximeyes] [http://heyclassylady.ifrance.com/html/roma-di.htm roma di notte] [http://pegasik.ifrance.com/html/jeans-diesel/ jeans diesel] [http://pegasik.ifrance.com/html/www-calzedonia/ www calzedonia com] [http://cannotspell.ifrance.com/description/lib/evanessence-immortal/ evanessence immortal] [http://last-shadow.ifrance.com/text/directory/divini-rea/ divini rea] [http://fishing-gro.ifrance.com/html/ministero-sanita/ ministero sanita] [http://lady-mosquito.ifrance.com/web/ray-ban/ ray ban 5021] [http://uo-ination.ifrance.com/lib/microsoft-compact/ microsoft compact mouse] [http://zonkismusik.ifrance.com/img/styles/catamarani.htm catamarani] [http://orbzine.ifrance.com/images/small/clone-dvd.htm clone dvd css] [http://fishing-gro.ifrance.com/html/pio-marcello/ pio marcello pieri] [http://rielethuil.ifrance.com/description/lib/caricatore-fogli.htm caricatore fogli scanner] [http://fishing-gro.ifrance.com/html/testi-balli/ testi balli di gruppo] [http://epireial-h.ifrance.com/topic/www-ersu.htm www ersu unict it] [http://ryandrablya.ifrance.com/lib/foto-di.htm foto di puttane] [http://last-shadow.ifrance.com/text/directory/cavo-da/ cavo da rgb a component] [http://uo-ination.ifrance.com/lib/piccolo-cellulari/ piccolo cellulari samsung] [http://la-seras.ifrance.com/library/html/rasoi-braun.htm rasoi braun lavabile] [http://fishing-gro.ifrance.com/html/miceti/ miceti] [http://lauashbu.ifrance.com/lib/racconti-maestre/ racconti maestre] [http://orbzine.ifrance.com/images/small/ram-.htm ram 512 266 sdram] [http://uo-ination.ifrance.com/lib/videoregistratore-dvd/ videoregistratore dvd hdd] [http://zonkismusik.ifrance.com/img/styles/guerriero-strada.htm guerriero strada] [http://stasiia.ifrance.com/img/styles/caricatore-cd/ caricatore cd mp3] [http://heyclassylady.ifrance.com/html/acer-aspire.htm acer aspire 2000] [http://rielethuil.ifrance.com/description/lib/www-secondamano.htm www secondamano] [http://uo-ination.ifrance.com/lib/comune-di/ comune di castiglione dei pepoli bologna] [http://uo-ination.ifrance.com/lib/ecco-quel/ ecco quel che abbiamo] [http://bagrec.ifrance.com/lib/k-theme.htm k700 theme] [http://last-shadow.ifrance.com/text/directory/villa-lusso/ villa lusso] [http://fishing-gro.ifrance.com/html/selvaggia-pappalardo/ selvaggia pappalardo] [http://me4tateljnitsa.ifrance.com/data/las-chicas/ las chicas del can] [http://stasiia.ifrance.com/img/styles/hal/ hal] [http://butanexlove.ifrance.com/lib/modena-city.htm modena city rambler] [http://cannotspell.ifrance.com/description/lib/un-osito/ un osito de peluche de taiwan] [http://pegasik.ifrance.com/html/micro-hi/ micro hi fi dvd] [http://cannotspell.ifrance.com/description/lib/volkswagen-passat/ volkswagen passat variant tdi 130 cv] [http://uo-ination.ifrance.com/lib/memorie-gb/ memorie 1gb] [http://gmkamm.ifrance.com/view/new/trasloco-bologna.htm trasloco bologna] [http://lady-mosquito.ifrance.com/web/volkswagen-golf/ volkswagen golf benzina] [http://heyclassylady.ifrance.com/html/what-s.htm what s your number] [http://uo-ination.ifrance.com/lib/dimmu-bogir/ dimmu bogir] [http://epireial-h.ifrance.com/topic/rex-fi.htm rex fi 22] [http://me4tateljnitsa.ifrance.com/data/ne-dolazi/ ne dolazi] [http://last-shadow.ifrance.com/text/directory/macchine-caffe/ macchine caffe] [http://cannotspell.ifrance.com/description/lib/goboy/ goboy] [http://epireial-h.ifrance.com/topic/the-two.htm the two of us] [http://last-shadow.ifrance.com/text/directory/laser-fronte/ laser fronte retro] [http://lauashbu.ifrance.com/lib/totem/ totem] [http://gmkamm.ifrance.com/view/new/seredova.htm seredova] [http://fishing-gro.ifrance.com/html/escape-on/ escape on elm street] [http://uo-ination.ifrance.com/lib/gare-di/ gare di rally] [http://lauashbu.ifrance.com/lib/iomega-usb/ iomega usb hard disk] [http://last-shadow.ifrance.com/text/directory/enigma-mcmxc/ enigma mcmxc ad the complete album] [http://zonkismusik.ifrance.com/img/styles/dvd-regionfree.htm dvd regionfree] [http://lady-mosquito.ifrance.com/web/animal-cum/ animal cum] [http://zonkismusik.ifrance.com/img/styles/carolina-marconi.htm carolina marconi tommaso vianello] [http://lady-mosquito.ifrance.com/web/passini/ passini] [http://epireial-h.ifrance.com/topic/amstrad-lcd.htm amstrad lcd 42] [http://lady-mosquito.ifrance.com/web/photo-di/ photo di alex max band] [http://epireial-h.ifrance.com/topic/profumi-dolce.htm profumi dolce gabbana uomo] [http://la-seras.ifrance.com/library/html/mappa-citta.htm mappa citta roma] [http://uo-ination.ifrance.com/lib/hille-peter/ hille peter] [http://cannotspell.ifrance.com/description/lib/portatile-asus/ portatile asus athlon 64] [http://lauashbu.ifrance.com/lib/jack-e/ jack e la notte di halloween] [http://heyclassylady.ifrance.com/html/mp.htm mp 3222] [http://sherryfraser03.ifrance.com/web/marco-pantano/ marco pantano] [http://lauashbu.ifrance.com/lib/video-de/ video de perreo] [http://me4tateljnitsa.ifrance.com/data/hdd-/ hdd 200 gb sata] [http://lauashbu.ifrance.com/lib/noleggiatori/ noleggiatori] [http://last-shadow.ifrance.com/text/directory/test-patentino/ test patentino on line] [http://cannotspell.ifrance.com/description/lib/cimo/ cimo] [http://butanexlove.ifrance.com/lib/tritacarne-elettrico.htm tritacarne elettrico] [http://sherryfraser03.ifrance.com/web/sordi-alberto/ sordi alberto] [http://zonkismusik.ifrance.com/img/styles/kleiner-juliusz.htm kleiner juliusz] [http://lauashbu.ifrance.com/lib/ram-/ ram 533 adata] [http://cannotspell.ifrance.com/description/lib/agriturismo-gorizia/ agriturismo gorizia] [http://fishing-gro.ifrance.com/html/mia-moglie/ mia moglie cerca singoli] [http://ryandrablya.ifrance.com/lib/empire-dv.htm empire dv av] [http://gmkamm.ifrance.com/view/new/gonfiabile-divano.htm gonfiabile divano] [http://lady-mosquito.ifrance.com/web/it-just/ it just wont do] [http://orbzine.ifrance.com/images/small/portami-via.htm portami via] [http://epireial-h.ifrance.com/topic/d-lgs.htm d lgs 277 91] [http://la-seras.ifrance.com/library/html/midi-colonne.htm midi colonne sonore] [http://fishing-gro.ifrance.com/html/buffy-screen/ buffy screen captures] [http://butanexlove.ifrance.com/lib/eta-aviazione.htm eta (aviazione)] [http://stasiia.ifrance.com/img/styles/registratore-mp/ registratore mp3 fm flash] [http://epireial-h.ifrance.com/topic/memoria-sdram.htm memoria sdram 256] [http://lauashbu.ifrance.com/lib/elenco-telefonico/ elenco telefonico pagine gialle vicenza] [http://bagrec.ifrance.com/lib/sting-mtv.htm sting mtv] [http://lauashbu.ifrance.com/lib/avi-gratuiti/ avi gratuiti] [http://rielethuil.ifrance.com/description/lib/iraq-video.htm iraq video deca] [http://zonkismusik.ifrance.com/img/styles/incontro-san.htm incontro san teodoro] [http://gmkamm.ifrance.com/view/new/amd-sempron.htm amd sempron 2400 box] [http://lady-mosquito.ifrance.com/web/aperto/ aperto] [http://orbzine.ifrance.com/images/small/merluzzo-al.htm merluzzo al latte] [http://pegasik.ifrance.com/html/i-don/ i don t want you back fuck it testo] [http://gmkamm.ifrance.com/view/new/noleggio-abiti.htm noleggio abiti cerimonia roma] [http://cannotspell.ifrance.com/description/lib/video-call/ video call] [http://bagrec.ifrance.com/lib/televisore-.htm televisore 14 philips] [http://lady-mosquito.ifrance.com/web/giochi-italiano/ giochi italiano] [http://lauashbu.ifrance.com/lib/nuovo-filmato/ nuovo filmato per life for speed] [http://epireial-h.ifrance.com/topic/xbox-controller.htm xbox controller] [http://sherryfraser03.ifrance.com/web/fuk-it/ fuk it testo in inglese] [http://epireial-h.ifrance.com/topic/logitech-z.htm logitech z2300 thx] [http://last-shadow.ifrance.com/text/directory/donne-quarantenni/ donne quarantenni] [http://bagrec.ifrance.com/lib/oki-w.htm oki 6w] [http://heyclassylady.ifrance.com/html/turner-.htm turner 2000 pro] [http://ryandrablya.ifrance.com/lib/magic-.htm magic 9 pc] [http://orbzine.ifrance.com/images/small/testi-canzoni.htm testi canzoni valeria lynch] [http://stasiia.ifrance.com/img/styles/globo-telecom/ globo telecom] [http://ryandrablya.ifrance.com/lib/ultra-fast.htm ultra fast] [http://butanexlove.ifrance.com/lib/lultimo-dei.htm lultimo dei banditi] [http://gmkamm.ifrance.com/view/new/edirol-uax.htm edirol ua1x] [http://cannotspell.ifrance.com/description/lib/fax-laser/ fax laser piano multifunzione] [http://orbzine.ifrance.com/images/small/sistiana.htm sistiana] [http://la-seras.ifrance.com/library/html/spicy-love.htm spicy love soup] [http://zonkismusik.ifrance.com/img/styles/katy-e.htm katy e diego] [http://stasiia.ifrance.com/img/styles/marche-di/ marche di automobili] [http://gmkamm.ifrance.com/view/new/bmw-e.htm bmw e36 1995] [http://epireial-h.ifrance.com/topic/gianluigi-buffon.htm gianluigi buffon] [http://la-seras.ifrance.com/library/html/goldberg-aria.htm goldberg aria] [http://butanexlove.ifrance.com/lib/under-your.htm under your spell] [http://lady-mosquito.ifrance.com/web/ilgladiatore/ ilgladiatore] [http://lady-mosquito.ifrance.com/web/porta-sezionale/ porta sezionale] [http://gmkamm.ifrance.com/view/new/moto.htm moto 50] == Setting up your environment ==
== Setting up your environment ==


Having a good environment setup is essential for everything you will be doing with Java ME - writing, compiling, packaging, debugging, obfuscating, tearing your hair out etc etc. Use the instructions here to setup your environment on Windows or OS X (currently experimental).  
Having a good environment setup is essential for everything you will be doing with Java ME - writing, compiling, packaging, debugging, obfuscating, tearing your hair out etc etc. Use the instructions here to setup your environment on Windows or OS X (currently experimental).  


<h2>Java   Wireless Toolkit</h2>
<h2>Java + Wireless Toolkit</h2>
#Java Standard Edition Development Kit (JDK) - you need to have some version of Java installed on your machine. Try to get version 1.4.2 (or later). This is essential for development. NOTE: You MUST have the JDK installed before you install the Java Wireless Toolkit as you will need the tools it contains (such as javac) to compile and run your MIDlets.
#Java Standard Edition Development Kit (JDK) - you need to have some version of Java installed on your machine. Try to get version 1.4.2 (or later). This is essential for development. NOTE: You MUST have the JDK installed before you install the Java Wireless Toolkit as you will need the tools it contains (such as javac) to compile and run your MIDlets.
#Download it here: http://java.sun.com/j2se/downloads/index.html. Get the version without any other bundled software. It should be called something like JDK 5.0 Update 8.
#Download it here: http://java.sun.com/j2se/downloads/index.html. Get the version without any other bundled software. It should be called something like JDK 5.0 Update 8.
Line 29: Line 29:
   <p>A good way to test if this worked is to type the preverify command without any arguments in the command line. You should see something like this on your screen. </p>
   <p>A good way to test if this worked is to type the preverify command without any arguments in the command line. You should see something like this on your screen. </p>
<pre>
<pre>
C:\> preverify<br />
C:\> preverify
Usage: PREVERIFY.EXE [options] classnames|dirnames ...<br />
Usage: PREVERIFY.EXE [options] classnames|dirnames ...
<br />
 
where options include:<br />
where options include:
   -classpath <directories separated by ';'><br />
   -classpath <directories separated by ';'>
                   Directories in which to look for classes<br />
                   Directories in which to look for classes
   -d <directory> Directory in which output is written <br />
   -d <directory> Directory in which output is written
   @<filename>    Read command line arguments from a text file.<br />
   @<filename>    Read command line arguments from a text file.
</pre>
</pre>


Line 48: Line 48:


<h3>Mac OS X</h3>
<h3>Mac OS X</h3>
None of the manufacturers have bothered to port their SDKs for the Mac, and neither has Sun, but there is a way to develop MIDP 1.0 and 2.0 applications using Apache Ant, MPowerplayer MIDP 2.0 SDK and J2ME Polish. Get 'em while they're hot:  
None of the manufacturers have bothered to port their SDKs for the Mac, and neither has Sun, but there are a number of ways to develop MIDP 1.0 and 2.0 applications on OS X using either
* MPowerplayer + EclipseME + Eclipse OR
* Apache Ant, MPowerplayer and J2ME Polish. OR
* Netbeans + MPowerplayer OR
* Mobile.Processing + MPowerplayer.
 
Whichever method you choose, you're going to need MPowerplayer.
 
<h5>MPowerplayer MIDP 2.0 SDK</h5>
# Download this from http://www.mpowerplayer.com/products-sdk.php
# Save the file somewhere in your src folder and unzip it. On my machine this looked like this:
<pre>
/Users/michael/src/mobile/mpp-sdk
</pre>
# [Optional] I like making shortcuts so that it's easy for me to run the application. Fire up your favourite editor and type this
<pre>java -jar /Users/michael/src/mobile/mpp/player.jar $1 &</pre>
and then save that somewhere in your path as '''mpp'''. I saved it as <pre>/Users/michael/mpp</pre>
Then, make it executable by typing:  
<pre>chmod 755 mpp</pre>
Now, all you need to do to run JAD/JAR files in the emulator is type <pre>mpp [filename.jad/filename.jar]</pre>
 
----


<h5>Apache Ant</h5>
<h5>Apache Ant (OPTIONAL - ONLY FOR J2ME POLISH USERS)</h5>
# Download Apache Ant from http://download.nextag.com/apache/ant/binaries/apache-ant-1.6.5-bin.tar.gz  
# Download Apache Ant from http://download.nextag.com/apache/ant/binaries/apache-ant-1.6.5-bin.tar.gz  
# Save it somewhere easy and memorable - on my machine I save all my downloaded source files to <pre>/Users/michael/src</pre>
# Save it somewhere easy and memorable - on my machine I save all my downloaded source files to <pre>/Users/michael/src</pre>
Line 83: Line 104:
This means that Ant is installed and we're ready to roll.
This means that Ant is installed and we're ready to roll.


<h5>MPowerplayer MIDP 2.0 SDK</h5>
<h5>J2ME Polish (OPTIONAL - ONLY FOR ADVANCED STUDENTS)</h5>
# Download this from http://www.mpowerplayer.com/products-sdk.php
# Download [http://j2mepolish.org/downloads/j2mepolish-2.0-beta1.html J2ME Polish]. I got the latest 2.0 beta version. It seems to work well.  
# Save the file somewhere in your src folder and unzip it. On my machine this looked like this:
# Run the downloaded JAR file
# Choose the GPL or Evaluation license
# Select the directory where you installed the MPP-SDK as the path to your wireless toolkit.  
# Test if everything installed correctly by running one of the J2ME Polish sample applications
<pre>
<pre>
/Users/michael/src/mobile/mpp-sdk
cd /Applications/J2ME-Polish/samples/menu
ant
</pre>
</pre>
# [Optional] I like making shortcuts so that it's easy for me to run the application. Fire up your favourite editor and type this
# You should see a few messages from Ant letting you know that it's building the application. The build is configured to store all the JAD and JAR files inside the dist folder.
<pre>java -jar /Users/michael/src/mobile/mpp/player.jar $1
# Once it's done, if you created a shortcut to the MPowerplayer SDK like I suggested above, you should be able to run it by typing something like
<pre>
mpp dist/Sony-Ericsson-P900-en_US-example.jad
</pre>
# I included a modified build.xml with extensive comments file in the [http://uberthings.com/teaching/mobile_application_design/1/code.zip HelloMidlet] code samples. Open it up in a text editor and read through to learn how it works.
 
<h5>Building</h5>
To build applications with J2ME Polish, Mpowerplayer and Ant, you need to do the following:
 
# Copy the build.xml file into your MIDlet's directory.
# Check the paths inside the build.xml file to ensure that they're pointing to the right folders for your source folders, Mpowerplayer and J2ME Polish
# Type ant. Watch the magic unfold.
 
<h2>IDE's</h2>
<h3>Eclipse</h3>
 
[http://eclipse.org Eclipse] is a fantastic open source Java Integrated Development Environment (IDE) which has a few sweet J2ME plugins. The one I use the most is called [http://eclipseme.org EclipseME]. <s>Although Eclipse is cross-platform, EclipseME doesn't work very well on OS X.</s> OS X works nicely with EclipseME and the MPowerplayer SDK.
 
'''Windows'''
 
# Download Eclipse from http://www.eclipse.org/downloads/. Install it somewhere easy - like C:\eclipse
# Configuring and install EclipseME using the excellent installation and configuration instructions [http://eclipseme.org/docs/installEclipseME.html here] to guide you through this process.
# Once you're done - we're ready to start coding! Yeah!
 
'''OS X'''
 
# Install EclipseME from the download site.
# Go to Window->Preferences. Select J2ME.
# When it asks you for the WTK Root - select the folder where you installed the Mpowerplayer SDK - for me it was /Users/michael/src/mobile/mpp-sdk.
# Go to Device Manager. Hit Import. Select the Mpowerplayer directory again. It will only find one emulator. Select it.
# Hit Apply. Then ok.
 
'''Initial Directory structures'''
# For my projects, I like to set up my source files in the /src folders of my projects and all external files to be in /res - this is how you do it in Eclipse.
[http://uberthings.com/teaching/mobile_application_design/i/j2me_setup.jpg J2ME Setup]
 
[http://uberthings.com/teaching/mobile_application_design/i/java_build_path.jpg Java Build Path]
 
<h3>Netbeans</h3>
Download Netbeans from Sun here - http://www.netbeans.org/. I don't use it much, but I've heard good things. Let me know how it treats you.
 
<h3>Mobile.Processing</h3>
 
[http://mobile.processing.org/ Mobile.Processing] is an open source programming environment for people who want to design and prototype software for mobile phones. It is based on and shares the same design goals as the open source [http://processing.org Processing ] project. Sketches programmed using Mobile Processing run on Java Powered mobile devices. Mobile.Processing is extremely easy to get up and running with, but has some drawbacks which will prevent us from using it.
 
Mobile.Processing is available for both Windows and Mac OS X. Download it [http://mobile.processing.org/download/index.php here].

Latest revision as of 20:10, 10 September 2007

Setting up your environment

Having a good environment setup is essential for everything you will be doing with Java ME - writing, compiling, packaging, debugging, obfuscating, tearing your hair out etc etc. Use the instructions here to setup your environment on Windows or OS X (currently experimental).

Java + Wireless Toolkit

  1. Java Standard Edition Development Kit (JDK) - you need to have some version of Java installed on your machine. Try to get version 1.4.2 (or later). This is essential for development. NOTE: You MUST have the JDK installed before you install the Java Wireless Toolkit as you will need the tools it contains (such as javac) to compile and run your MIDlets.
  2. Download it here: http://java.sun.com/j2se/downloads/index.html. Get the version without any other bundled software. It should be called something like JDK 5.0 Update 8.
  3. Java ME, Wireless Toolkit (WTK). This contains the essential tools that we need to build, package and install mobile applications. Download it here: http://java.sun.com/products/j2mewtoolkit/. Get the [J2ME Wireless Toolkit 2.2 http://java.sun.com/products/sjwtoolkit/download-2_2.html], or if you feel living on the bleeding edge - grab the Sun [Java Wireless Toolkit 2.5 for CLDC, Beta http://java.sun.com/products/sjwtoolkit/download-2_5.html](the toolkit formerly known as J2ME Wireless Toolkit). Careful, you may cut yourself.
  4. I'm going to assume that you will install this into the
    C:\WTK\
    directory - if you install it somewhere else, just modify the paths accordingly.

Paths

To play nicely with the grown-ups, Java needs to know where all your files are, so we need to add the location of the Java binaries to the system path.

Windows 95/98

Go to Start->Run. Type in command. Then type

SET PATH=%PATH%;C:\WTK\bin

You should also edit your C:\autoexec.bat file to include this line, so you don't have to enter it every single time you restart your computer. After you've done this, you should be able to run the tools included in the Java Wireless Toolkit from any directory on your system.

Windows 2000/XP

  1. Go to Control Panel -> System.
  2. Click on the Advanced Tab
  3. Click on the Environment Variables button
  4. Double-click the PATH variable in the System variables box
  5. At the end of the Variable value field, add the path to your J2ME WTK installation - for me this is something like ;C:\WTK
  6. If you had to install the J2SE SDK too, it's a good idea to add the paths for that as well - for me this was C:\j2sdk1.4.2_03;C:\j2sdk1.4.2_03\bin.

A good way to test if this worked is to type the preverify command without any arguments in the command line. You should see something like this on your screen.

C:\> preverify
Usage: PREVERIFY.EXE [options] classnames|dirnames ...

where options include:
   -classpath <directories separated by ';'>
                  Directories in which to look for classes
   -d <directory> Directory in which output is written
   @<filename>    Read command line arguments from a text file.

Emulators

Windows

Depending on your target device, you should download and install the SDK for that particular handset or family of handsets from the manufacturer's site. Since this course is based around the Nokia Series 60 handsets, we're going to grab the Nokia Series 60 2nd Edition SDK, Feature Pack 2 and 3 as well as the Nokia Series 60 3rd Edition SDK (for the N80). You'll also need to get serial numbers for these SDKs, so don't forget to request those as well. Download them from here:

Series 60 SDKs

Mac OS X

None of the manufacturers have bothered to port their SDKs for the Mac, and neither has Sun, but there are a number of ways to develop MIDP 1.0 and 2.0 applications on OS X using either

  • MPowerplayer + EclipseME + Eclipse OR
  • Apache Ant, MPowerplayer and J2ME Polish. OR
  • Netbeans + MPowerplayer OR
  • Mobile.Processing + MPowerplayer.

Whichever method you choose, you're going to need MPowerplayer.

MPowerplayer MIDP 2.0 SDK
  1. Download this from http://www.mpowerplayer.com/products-sdk.php
  2. Save the file somewhere in your src folder and unzip it. On my machine this looked like this:
/Users/michael/src/mobile/mpp-sdk
  1. [Optional] I like making shortcuts so that it's easy for me to run the application. Fire up your favourite editor and type this
java -jar /Users/michael/src/mobile/mpp/player.jar $1 &

and then save that somewhere in your path as mpp. I saved it as

/Users/michael/mpp

Then, make it executable by typing:

chmod 755 mpp

Now, all you need to do to run JAD/JAR files in the emulator is type

mpp [filename.jad/filename.jar]

Apache Ant (OPTIONAL - ONLY FOR J2ME POLISH USERS)
  1. Download Apache Ant from http://download.nextag.com/apache/ant/binaries/apache-ant-1.6.5-bin.tar.gz
  2. Save it somewhere easy and memorable - on my machine I save all my downloaded source files to
    /Users/michael/src
  3. Here is the process. To try keep things clean, we're going to be installing into /usr/local.
tar -zxvf apache-ant-1.6.5-src.tar.gz
cd /usr/local
sudo mkdir ant
cd ant
sudo cp -R ~/src/apache-ant-1.6.5/bin .
sudo cp -R ~/src/apache-ant-1.6.5/lib .
  1. Set up the paths in your environment
pico ~/.bash_login

Add these lines somewhere

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/Library/Java/Home
export PATH=${PATH}:${ANT_HOME}/bin

Shut down your shell, open it up again and type

ant

You should see something like this 

Buildfile: build.xml does not exist!
Build failed

This means that Ant is installed and we're ready to roll.

J2ME Polish (OPTIONAL - ONLY FOR ADVANCED STUDENTS)
  1. Download J2ME Polish. I got the latest 2.0 beta version. It seems to work well.
  2. Run the downloaded JAR file
  3. Choose the GPL or Evaluation license
  4. Select the directory where you installed the MPP-SDK as the path to your wireless toolkit.
  5. Test if everything installed correctly by running one of the J2ME Polish sample applications
cd /Applications/J2ME-Polish/samples/menu
ant
  1. You should see a few messages from Ant letting you know that it's building the application. The build is configured to store all the JAD and JAR files inside the dist folder.
  2. Once it's done, if you created a shortcut to the MPowerplayer SDK like I suggested above, you should be able to run it by typing something like
mpp dist/Sony-Ericsson-P900-en_US-example.jad 
  1. I included a modified build.xml with extensive comments file in the HelloMidlet code samples. Open it up in a text editor and read through to learn how it works.
Building

To build applications with J2ME Polish, Mpowerplayer and Ant, you need to do the following:

  1. Copy the build.xml file into your MIDlet's directory.
  2. Check the paths inside the build.xml file to ensure that they're pointing to the right folders for your source folders, Mpowerplayer and J2ME Polish
  3. Type ant. Watch the magic unfold.

IDE's

Eclipse

Eclipse is a fantastic open source Java Integrated Development Environment (IDE) which has a few sweet J2ME plugins. The one I use the most is called EclipseME. Although Eclipse is cross-platform, EclipseME doesn't work very well on OS X. OS X works nicely with EclipseME and the MPowerplayer SDK.

Windows

  1. Download Eclipse from http://www.eclipse.org/downloads/. Install it somewhere easy - like C:\eclipse
  2. Configuring and install EclipseME using the excellent installation and configuration instructions here to guide you through this process.
  3. Once you're done - we're ready to start coding! Yeah!

OS X

  1. Install EclipseME from the download site.
  2. Go to Window->Preferences. Select J2ME.
  3. When it asks you for the WTK Root - select the folder where you installed the Mpowerplayer SDK - for me it was /Users/michael/src/mobile/mpp-sdk.
  4. Go to Device Manager. Hit Import. Select the Mpowerplayer directory again. It will only find one emulator. Select it.
  5. Hit Apply. Then ok.

Initial Directory structures

  1. For my projects, I like to set up my source files in the /src folders of my projects and all external files to be in /res - this is how you do it in Eclipse.

J2ME Setup

Java Build Path

Netbeans

Download Netbeans from Sun here - http://www.netbeans.org/. I don't use it much, but I've heard good things. Let me know how it treats you.

Mobile.Processing

Mobile.Processing is an open source programming environment for people who want to design and prototype software for mobile phones. It is based on and shares the same design goals as the open source Processing project. Sketches programmed using Mobile Processing run on Java Powered mobile devices. Mobile.Processing is extremely easy to get up and running with, but has some drawbacks which will prevent us from using it.

Mobile.Processing is available for both Windows and Mac OS X. Download it here.