 |
Build Recipe: Windows Mobile
Building a CDC Java runtime environment for Windows Mobile
requires integration of the CDC build system
with conventional Windows Visual Studio developer tools.
The following sections show how to
setup the CDC build system on a Windows XP host platform,
and then build different versions of the CDC Java runtime environment
that will also run on a Windows Mobile/Pocket PC device or emulator.
Platform Notes
The MIDP implementation is built on top of the functionality of Foundation Profile without exposing the APIs of Foundation Profile to applications.
For graphics functionality, the MIDP/LCDUI implementation is based directly on the Windows Mobile graphics layer.
Note that the Personal Basis Profile implementation is not yet supported on Windows Mobile
and therefore xlet support is also not yet available.
The platform-dependent layer of the Windows Mobile implementation of phoneME Advanced is based on the Windows Mobile 5.0 Pocket PC SDK.
The runtime is compatible with both Windows Mobile 5 and 6.x.
Build System Setup
Required Developer Tools
- Cygwin is a Linux-like environment for Windows with a package management system that allows libraries and applications to be easily downloaded and upgraded. The following Cygwin packages are necessary for development with the CDC build system on Windows XP:
- binutils
- bison
- diffutils
- flex
- gcc-g++
- make
- perl
- subversion
- zip/unzip
- Microsoft Windows Visual Studio is the standard tool suite for Windows software development. The following tools, service packs and SDKs are needed for development with the CDC build system on Windows XP:
Required Project Components
After installing and updating the required developer tools for the CDC build system,
you can get the project source code
by either downloading the project source code bundle (appropriate for evaluation purposes)
or checking out the project source code from the repository.
These procedures are described in
Getting the Project Source Code.
The required phoneME Advanced project components for building Foundation Profile are:
The additional required phoneME Advanced project components for building MIDP are:
The additional required phoneME Advanced project components for building an optional package are:
It's best to keep each of these component directories in the same top-level directory (e.g. C:/phoneme).
Note:
The CDC build system has some dependencies on the way pathnames are used in a UNIX environment.
To make this work more smoothly in the Cygwin environment
you must mount the installation directory onto a top-level Cygwin directory.
For example, if the installation directory is C:/pmea,
then the following commands will mount the installation directory
onto the top-level /pmea directory.
It is important that the directory and the mount point have the same name.
$ mkdir C:/pmea
$ mkdir /pmea
$ mount C:/pmea /pmea
|
|
Note:
The following patches must be applied to the javacall directory:
|
Building phoneME Advanced
Building Foundation Profile
With the required developer tools and project source code in place,
the next step is to create a driver script named build-fp.sh to run the build process.
The following script builds a basic Foundation Profile target:
#!/bin/sh
make \
JDK_HOME=C:/j2sdk1.4.2_18 \
J2ME_CLASSLIB=foundation \
CVM_JIT=true \
CVM_PRELOAD_LIB=true
After modifying this script it can be invoked as follows:
$ sh < build-fp.sh >& err &
Note:
The Microsoft Visual Studio setup script
C:/Program Files/Microsoft Visual Studio 8/Common7/Tools/vsvars32.bat
defines the variable LIBPATH. This may cause the build to fail
because it tries search that path which is interpreted incorrectly since it is a Windows
path with backslash characters. In that case simply set the variable to an empty string:
$ export LIBPATH=
|
Note:
The tools should be placed in the tools directory at the same level as the $TOP_DIR/cdc directory.
If the build script can't find the tools the you must set the TOOLS_DIR variable.
TOOLS_DIR=<location>/tools
|
Note:
Running the build-fp.sh script should be done from the cdc/build/win32-arm-wm5 directory.
Adding
$ cd cdc/build/win32-arm-wm5
to the beginning of the build script to change to the directory automatically may fail.
If you want to cd to the build directory in the script use
$ make -C $TOP_DIR/cdc/build/win32-arm-wm5 ... (rest of make command line)
instead.
|
Building MIDP
And finally here's a build driver script named build-midp.sh for building MIDP:
#!/bin/sh
make \
JDK_HOME=C:/j2sdk1.4.2_18 \
J2ME_CLASSLIB=foundation \
CVM_JIT=true \
CVM_PRELOAD_LIB=true \
CVM_BUILD_SUBDIR_NAME=cdc-midp \
USE_JPEG=true \
USE_MIDP=true
After modifying this script it can be invoked as follows:
$ sh < build-midp.sh >& err &
|
Note:
If you have problems with the build and need to start over, it's best to run make clean
before relaunching a failed build.
Some of the project components retain build state that needs to be cleaned out.
|
Runtime Examples
After the build process successfully finishes, the CDC Java runtime environment
is available as runtime executable located in a few target directories,
most importantly the bin and lib directories.
The Microsoft Device Emulator can be used to test the CDC Java runtime environment.
The first task with using the device emulator
is to install the Java runtime environment within the emulator environment.
-
Create a Windows directory named "Storage Card".
$ mkdir C:/Documents\ and\ Settings/User/Desktop/Storage\ Card
-
Copy the CDC Java runtime environment executable files from the target build directory to the shared directory.
This should include the bin and lib directories
and the testclasses.zip archive file.
$ cp -r bin lib midp testclasses.zip /cygdrive/c/Documents\ and\ Settings/User/Desktop/Storage\ Card/
-
Launch the Microsoft Device Emulator.
$ C:/Program Files/Microsoft Device Emulator/1.0/dvcemumanager.exe
-
Select the shared folder.
-
Connect to the Windows Mobile 5.0 Pocket PC device emulator.
-
On the emulator screen choose File->Configure.
The Emulator Properties dialog will display.
-
Under the Shared folder: edit box, select the newly created Storage Card directory.
-
Click on the 'OK' button to share the directory.
-
(Optional).
Set the Device Emulator RAM size to 256 MB.
-
On the Device Emulator,
navigate to the File Explorer
application and select the Storage Card.
Foundation Profile Example
-
Create a .lnk file for launching the CDC Java runtime environment.
Note that paths used in the .lnk file
are relative to the Storage Card root.
For example, here is a basic test-fp.lnk file to launch cvm and run the HelloWorld application:
01#"\Storage Card\bin\cvm.exe" -f "\Storage Card\fp-args.txt"
-
Create an args.txt file to contain the arguments for cvm.exe.
For example, the fp-args.txt file contains the following:
"-Xopt:stdioPrefix=\Storage Card" -Xmx2m "-Djava.class.path=\Storage Card\testclasses.zip" HelloWorld
-
Launch the HelloWorld application by double-clicking on the test-fp list item.
HelloWorld displays text on the standard output,
so the results of this application are not immediately apparent.
To see the standard output of the HelloWorld application,
look at the OUT.txt file in the Storage Card directory.
MIDP Example
The example below is based on running a MIDlet locally.
-
Create a .jar file containing a manifest file and a sample MIDlet .
-
Copy the .jar file to the shared folder.
-
Create a .lnk file for the MIDlet.
It should be very similar to the .lnk file described in the previous example.
-
Create an args.txt file for the MIDlet:
-Xmx2m -Dmicroedition.profiles=MIDP-2.1 -Dsun.midp.library.name=midp "-Dsun.midp.home.path=\Storage Card\midp\midp_wince" -Dcom.sun.midp.mainClass.name=com.sun.midp.main.CdcMIDletSuiteLoader sun.misc.MIDPLauncher -midppath "\Storage Card\midp\midp_wince\classes" -suitepath "\Storage Card\HelloWorld.jar" -1 HelloWorld
If you have problems launching the MIDlet you can add "-Xopt:stdioPrefix=/Storage Card" to args.txt to have output and errors written to the root of the storage card.
-
Launch the .lnk file as in the previous example.
|