logoTop pad
logoBottom
Donate!
Home
License
Prerequisites
News
Installation
Documentation
Downloads
Support
Sourceforge Project Page


Eclipse Ready Logo

Repairing Sun’s WTK After a JDK Upgrade

Craig Setera — December 21, 2008 @ 5:32 pm — Miscellaneous

I have managed to get behind on the state of the Eclipse Mobile Tools for Java code. In an effort to catch up, I downloaded the latest code to my Ubuntu box and started up a runtime workbench. At that point, I needed to import my devices into the workspace and pointed to my Sun 2.5.2 Wireless Toolkit installation. To my surprise, it failed to be recognized. Given that I had fixed a similar problem prior to the MTJ 0.9.0 release, I was surprised to see a return of the problem.
Before digging too far into the MTJ code, I decided to see that the emulator was actually working correctly. I changed into the WTK emulator directory and attempted to run the emulator directly.

setera@ubuntu-laptop:~/software/wtk252/bin$ ./emulator
./emulator: 26: /usr/lib/jvm/java-1.5.0-sun/bin/java: not found

Ah Ha! My emulator installation is broken. What’s going on?

setera@ubuntu-laptop:~/software/wtk252/bin$ java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)

Sure enough, I remember recently updating my Java installation on this machine and deleting the older Java 5 installation. Of course, I had forgotten that the Sun WTK writes these files during installation . Edit the emulator file with a text editor and sure enough you can see that the installation path is hardcoded within the shell script file.

#!/bin/sh
javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/

In fact, all of the shell scripts in the WTK bin folder have the incorrect Java installation folder.

setera@ubuntu-laptop:~/software/wtk252/bin$ grep "/usr/lib/jvm/java-1.5.0-sun/bin/" *
defaultdevice:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
emulator:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
i18ntool:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
ktoolbar:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
mekeytool:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
prefs:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
siptool:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
utils:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/
wscompile:javapathtowtk=/usr/lib/jvm/java-1.5.0-sun/bin/

A bit of searching on my machine tells me that Java is linked into /usr/bin.

setera@ubuntu-laptop:~/software/wtk252/bin$ which java
/usr/bin/java

The safest configuration is to point to the actual installation folder. Following a few links yields the installation path of /usr/lib/jvm/java-6-sun/jre/bin

setera@ubuntu-laptop:~/software/wtk252/bin$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2008-11-02 07:18 /usr/bin/java -> /etc/alternatives/java
setera@ubuntu-laptop:~/software/wtk252/bin$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 36 2008-11-02 07:18 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java

Editing the shell scripts and replacing the incorrect Java installation path with the correct path corrects the WTK installation and allows it to be used within MTJ again.

setera@ubuntu-laptop:~/software/wtk252/bin$ ./emulator
Syntax:

emulator [arguments] <Application>

If you end up having trouble importing or otherwise running a Sun WTK emulator on Linux, you may want to try looking at your installation to see if you have a similar problem.

2 Responses to “Repairing Sun’s WTK After a JDK Upgrade”

  1. Hal Mueller Says:

    I think this may be the root of my problem as well, except I run Windows XP where JavaME SDK 3.0 is not recognized. Will I need to edit the shell scripts (sutiably modified) as you indicated as well?

  2. Craig Setera Says:

    Hal,

    There have been sporadic problems with the 3.0 SDK. These should be fixed in MTJ. If you aren’t using MTJ, you should be. If you are using MTJ, your best bet is to go to the user’s newsgroup and ask for help specifically for MTJ.

    While I’m a committer on the MTJ project, I have very little time these days and I’m heading out of town for the next week. You will have much better luck if you ask this question over on the MTJ newgroups.

    Craig


Copyright © 2005, http://www.eclipseme.org. All rights reserved.