| C H A P T E R 3 |
|
Quick Start: Building on Linux for Linux |
This chapter describes a self-hosted Linux build, which means that you build and run the Java Wireless Client software on the same Linux machine. The goal of this chapter is to get you from zero to a functional MIDP software stack as fast as possible. Later chapters describe all the options for each part of the build.
Linux builds come in two flavors:
This chapter describes how to perform the linux_fb_gcc build.
This chapter is based on example scripts that help you run the different parts of the build. The scripts are available in docs/build-scripts/linux-x86. Once you have everything set up, run the scripts to perform the build. Work along as you read through the chapter to understand how it all fits together.
Most of the time, Linux already has most of the tools you need. These examples show how to find out if you have these tools available. If you do not, you will need to install the appropriate tools and adjust your PATH to include them.
$ make --version
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
$
On your computer, GNU Make might be gmake instead of make.
$ gcc --version
3.3.4
$
$ java -version
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition
(build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
$ javac
Usage: javac <options> <source files>
where possible options include:
...
$
Each of the build scripts in the rest of this chapter operate by setting up, doing some work, and cleaning up.
The setting up script is setup.sh and the cleaning up script is teardown.sh.
export Acme=/home/jonathan/jwc export JDK_DIR=/usr/java/j2sdk1.4.2_08 export Scripts=`pwd` export Output=$Acme/output export Log=$Acme/log.txt rm -f $Log |
This script is available as docs/build-scripts/linux-x86/setup.sh.
The Acme variable is the top level of the Java Wireless Client software. Adjust the value to point to the top level of your own installation. Also, make sure JDK_DIR points to the top directory of your JDK.
Don't run setup.sh yet. It is used by the build scripts in the rest of this chapter.
You do not need to modify this script.
The first step is to build PCSL. Tell PCSL the target platform and where to put output files. Set PCSL_PLATFORM to linux_i386_gcc. Tell PCSL where to put its output files with the PCSL_OUTPUT_DIR variable.
In addition, tell PCSL what kind of networking implementation to use. Do this by setting NETWORK_MODULE to bsd/generic.
Here is a script, build-pcsl.sh, that performs the build:
This script uses the setup.sh and teardown.sh script from before.
A series of build messages will be displayed, with a message at the end about the success of the PCSL build.
The output goes in $Acme/output/pcsl. Take a look:
/home/jonathan> ls jwc/output/pcsl linux_i386 /home/jonathan> ls jwc/output/pcsl/linux_i386 inc lib obj /home/jonathan> |
CLDC is built on top of PCSL. Tell CLDC to use PCSL by setting ENABLE_PCSL to true, and specify where to find PCSL with PCSL_OUTPUT_DIR.
In addition, the CLDC build system expects you to define various environment variables, as follows:
The following script, build-cldc.sh, runs the CLDC build.
Go ahead and give it a try with sh build-cldc.sh. Wait for a success message at the end of the build, and take a look at the generated files in output/cldc.
The last step in creating a Java Wireless Client software stack is building MIDP and optional APIs. This chapter describes how to build MIDP only. Later chapters describe how to include optional APIs in this part of the build and the many variables you can use to change how Java Wireless Client software is built.
For now, build MIDP using the CLDC and PCSL output you already generated.
You need JDK_DIR defined, just as it was for the CLDC build. In addition, you must tell the MIDP build where to find PCSL and CLDC:
The first thing that happens with the MIDP build is that tools are created for use later in the build. Use TOOLS_DIR to point to the tools directory.
Finally, set MIDP_OUTPUT_DIR to the location that contains the output of the build when it is complete.
Run the build from the midp/build/linux_fb_gcc directory. Here is a script, build-sjwc.sh, that sets the necessary variables and runs the MIDP build:
Run sh build-sjwc.sh without modifying the script. Wait until you see the message sjwc_status=OK at the end of the build. Congratulations! You've just built a complete MIDP stack.
The fb build of the Java Wireless Client software uses a framebuffer for display and user input. Use the Qt tool qvfb to see the simulated screen of the device and provide keyboard input. qvfb supports up to ten independent displays, numbered from :0 through :9.
Pick an available display and set QWS_DISPLAY to its number. Next, run qvfb with a bit depth of 16. Adjust the size of the framebuffer to match the expectations of the Java Wireless Client software.
Run docs/build-scripts/linux-x86/run-qvfb.sh if you wish. The qvfb window appears, but it is empty.
Now run the Java Wireless Client software. Set QTDIR and QWS_DISPLAY the same as before. Then run the usertest command.
See docs/build-scripts/linux-x86/run-usertest.sh for an example.
The Java Wireless Client software runs in the qvfb window. Use your keyboard for input, if necessary. You might have to click in the qvfb window before using the keyboard. Use F1 and F2 for the soft buttons.
FIGURE 3-1 MIDlet Running in the qvfb Window.
You can install and test MIDlets on this simulated device. See the Tools Guide for complete details.
Copyright © 2007, Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL.