Monday 27 February 2012

Setting up J2ME and WTK.


Trying to develop an app for J2ME is quite a pain, as a lot of time will be spent in setting up this very outdated piece of software. In this guide I assume readers will be using a Unix based operating system, and have basic knowledge of using the terminal.

No matter what architecture you have (x86 or x64), you will need to download everything in x86. Therefore I suggest creating a new workspace if using eclipse, otherwise it will mess up with things you don't want it to.

In this guide I am assuming you use /opt/ as your base directory, but feel free to replace that with any directory.

Now, Sun's WTK only runs with a 32bit JRE, you need to manually download Sun/Oracle JRE but for x86 and extract it to a local folder.
(http://www.oracle.com/technetwork/java/javase/downloads/jre-6u31-download-1501637.html)

Then you also need to manually download Sun Java Wireless Toolkit 2.5.2_01 from sun's website and extract it. I used /opt/wtk/
(http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javame-419430.html#sun_java_wireless_toolkit-2.5.2_01b-oth-JPR)

After that, cd to ~/Downloads and:

$ chmod +x sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh
$ chmod +x jre-6u31-linux-i586.bin

so you can execute both files.

First:

$ ./jre-6u31-linux-i586.bin

and install the JRE (I installed it in /opt/bin32-jre/ ), and then

$ ./sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh

and follow the on-screen instructions to install the WTK. I installed the WTK in /opt/wtk/ . The WTK will ask you for your JRE directory, but it actually needs the bin directory of your jre. Therefore link it to /opt/bin32-jre/jre/bin/ , or without the final / if it doesn't work. Again, if it still gives you errors try /opt/bin32-jre/jre/ and again then without the final slash.

After you are done with the installation, you will need to make sure the correct JRE is being used. Manually edit /opt/wtk/bin/emulator and /opt/wtk/bin/ktoolbar with your favourite text editor as follows:

javapathtowtk=/opt/bin32-jre/jre/bin/

Note that you will need that last / after bin.
If either file doesn't have this variable, you will need to manually edit the path 4 lines from the bottom:

"/opt/bin32-jre/jre/bin/java" -Dkvem.home="${KVEM_HOME}" \     -Djava.library.path="${KVEM_HOME}/bin" \     -cp "${KVEM_LIB}/kenv.zip:${KVEM_LIB}/ktools.zip:${KVEM_LIB}/customjmf.     com.sun.kvem.environment.EmulatorWrapper "$@" 0

so that the beginning of the line has the exact path to your java executable, in the 32 bit JRE folder.

Finally, within eclipse (assuming you have installed JavaME plugin) you need to go to Window -> Preferences and click J2ME, then add the path to their WTK Root: /opt/wtk/ and the path to your Antenna JAR (mine was /home/silentz0r/.eclipse/org.eclipse.platform_3.6.1_1543616141/plugins/antenna.preprocessor.v2_1.7.7.jar ).

Feel free to ask any questions, Hope this helps.

No comments:

Post a Comment