Tech Tip: How to Fix the J2ME Wireless Toolkit After You Re-Install the Java
Development Kit
Contributed by
Lukas
Hasik and maintained by
Anatole Wilson, 06 Feb 2006
If you manually install a version of the J2ME Wireless Toolkit on your system,
the installation can break if you upgrade your Java Development Kit (JDK) or
reinstall the JDK in a new directory. This occurs because the JDK installation
directory is hard-coded in the Wireless Toolkit's scripts.
Note that this problem occurs only with versions of the Wireless Toolkit that
you have installed by yourself. The Mobility Pack automatically changes the
path in scripts in the bundled Wireless Toolkit that is in your userdir.
The Broken Wireless Toolkit
If the installation is broken, you will see a message like the one below when
you run a project using the broken WTK as the platform emulator in the NetBeans
Mobility Pack.
run:
Starting emulator in execution mode
<path_to_your_project>\nbproject\build-impl.xml:295: Execution failed
with error code 1.
BUILD FAILED (total time: 1 second)
The Wireless Toolkit also can not be launched either from the command line or the Start menu.
Fixing the Broken Wireless Toolkit Installation
You can easily recover from this situation if you change the JDK path in the
WTK scripts for existing JDK installation directory. You will have to change
the path at least in these three files in the bin directory in
the WTK installation directory:
-
emulator.bat
-
prefs.bat
utils.bat
(There are more script files in the WTK _bin_ directory but only
these three files are necessary for running the emulator, its preferences, and
utilities in the NetBeans Mobility Pack)
Open the files in any text editor and replace the path to uninstalled JDK with
the path to the newly installed JDK. Your Wireless Toolkit then starts to work
again.
Example of the Replaced JDK Installation Path in emulator.bat
For this example, the original JDK was installed in the C:\Program Files\Java\Jdk1.5.0_05
directory. The new JDK is installed in C:\Program Files\Java\Jdk1.5.0_06
directory.
If the original path was:
C:\PROGRA~1\Java\JDK15~1.0_0\bin\java.exe -Dkvem.home=G:\emulators\wtk2.3beta
-Djava.library.path=G:\EMULAT~1\WTK2~1.3BE/bin -Dsun.java2d.ddlock=true
-Dsun.java2d.gdiblit=false -cp G:\EMULAT~1\WTK2~1.3BE/wtklib/kenv.zip;
G:\EMULAT~1\WTK2~1.3BE/wtklib/ktools.zip;G:\EMULAT~1\WTK2~1.3BE/wtklib/customjmf.jar
com.sun.kvem.environment.EmulatorWrapper
The fixed path is:
C:\Program Files\Java\Jdk1.5.0_06\bin\java.exe
-Dkvem.home=G:\emulators\wtk2.3beta
-Djava.library.path=G:\EMULAT~1\WTK2~1.3BE/bin -Dsun.java2d.ddlock=true
-Dsun.java2d.gdiblit=false -cp G:\EMULAT~1\WTK2~1.3BE/wtklib/kenv.zip;
G:\EMULAT~1\WTK2~1.3BE/wtklib/ktools.zip;G:\EMULAT~1\WTK2~1.3BE/wtklib/customjmf.jar
com.sun.kvem.environment.EmulatorWrapper