J2ME on Mac OSX

I want to try to develop J2ME applications on my MacBook runnin Leopard. Luckily someone figured out that it is possible, although not so easy as on Windows or on Linux. On this page I try to describe the exact steps that are needed.

The instructions are based on this blog:
[http://javablog.co.uk/2008/01/17/j2me-development-on-os-x-revisited/]

Step one: Installing Sun WTK

You need to know the Java home on OSX and you need to download the Sun WTK for Linux.

Java home on Mac OSX:
[http://developer.apple.com/qa/qa2001/qa1170.html]

In short: “The equivalent on Mac OS X should always be /Library/Java/Home.”

Installing Sun WTK on Mac OSX:
[http://moritzpetersen.de/index.php/archives/2005/12/18/installing-j2me-wireless-toolkit-on-mac-os-x/]

In short:

  1. Open a terminal window
  2. Go to the downloaded .bin file
  3. Make the file executable: chmod +x sun_java_wireless_toolkit-2_5_2-linux.bin
  4. Execute the file: ./sun_java_wireless_toolkit-2_5_2-linux.bin

You will see a License you have to scroll through and you have to accept, then you need to enter the Java home:

  1. yes
  2. 0
  3. /Library/Java/Home/bin

The installation process

Do you agree to the above license terms? [yes or no] yes


No suitable Java interpreter was detected

0) Specify a path to a Java interpreter directory.
1) Cancel this installation.
Select a choice [0-1]: 0

This application requires Java 2 SDK, Standard Edition (1.5 or later). Enter a 
path to a Java 2 SDK (For example: /user/jdk1.5/bin). You can type "exit" to 
cancel installation.
Enter a path to the Java 2 SDK: /Library/Java/Home/bin
/Library/Java/Home/bin/java
Testing /Library/Java/Home/bin/java...

Please enter a directory into which you would like to install the Sun Java(TM)
Wireless Toolkit, 2.5.2 for CLDC.
[ default is /Users/martijn/Data/Java/SunWtk-linux/WTK2.5.2 ]:

...

Check for Product Updates? [yes or no] yes

Setup has enough information to start copying the program files.
Current Settings:
Destination Directory
  /Users/martijn/Data/Java/SunWtk-linux/WTK2.5.2/
JVM Folder
  /Library/Java/Home/bin/
Check for Program Updates
  Enabled

Please choose one of the following options:
0) Begin copying files if you are satisfied with the settings  .
1) Cancel the installation.
Select a choice [0-1]: 0
Checksumming...

Extracting the installation files...
Documentation for the Sun Java(TM) Wireless Toolkit 
2.5.2 for CLDC is in the file
  /Users/martijn/Data/Java/SunWtk-linux/WTK2.5.2/index.html
In order to start using the Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC, please run
  /Users/martijn/Data/Java/SunWtk-linux/WTK2.5.2/bin/ktoolbar
Macintosh:SunWtk-linux martijn$ 

Testing the installation

Macintosh:WTK2.5.2 martijn$ ./bin/ktoolbar 
Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.sun.kvem.environment.Resources.<init>(Unknown Source)
	at com.sun.kvem.environment.Resources.<clinit>(Unknown Source)
	at com.sun.kvem.environment.ToolkitDirs.<clinit>(Unknown Source)
	at com.sun.kvem.toolbar.Main$SplashWindow.<init>(Unknown Source)
	at com.sun.kvem.toolbar.Main.main(Unknown Source)
Caused by: java.io.FileNotFoundException:
/Users/martijn/Data/Java/SunWtk-linux/WTK2.5.2/wtklib/Mac/ktools.properties (No such   file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	... 5 more
Macintosh:WTK2.5.2 martijn$ 

Getting ktoolbar to actually work

This can be fixed by copying ktool.properties:

Macintosh:WTK2.5.2 martijn$ cd wtklib/
Macintosh:wtklib martijn$ mkdir Mac
Macintosh:wtklib martijn$ cp ./Linux/ktools.properties ./Mac/
Macintosh:wtklib martijn$ 

Testing again, now I can start ktoolbar

I can start ktoolbar and the GUI starts up. The console shows the following:

Macintosh:wtklib martijn$ cd ..
Macintosh:WTK2.5.2 martijn$ ./bin/ktoolbar 
OTA server emulation started ...
HTTPS server emulation started ...
Macintosh:WTK2.5.2 martijn$ 
java/j2me-on-mac-osx.txt · Last modified: 2012/04/14 15:13 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki