Native UltraLite for Java User's Guide
Tutorial: An Introductory Application
Running the application on Windows CE requires that the Jeode Runtime Java VM be installed on your device. The Jeode Runtime is available for ARM-based devices such as the Compaq iPaq, and can be found on the CD that comes with the device.
To confirm that the Jeode VM is installed on your Windows CE device
Choose Start
A Jeode folder is listed in the Programs folder.
To prepare your application to run on a Windows CE device
Specify the location of your database file and schema file.
In the Customer constructor, alter the CreateParms object to read as follows:
CreateParms parms = new CreateParms(); parms.databaseOnDesktop = "c:\\tutorial\\java\\tutcustomer.udb"; parms.databaseOnCE = "\\UltraLite\\tutorial\\tutcustomer.udb"; parms.schema.schemaOnDesktop = "c:\\tutorial\\java\\tutcustomer.usm"; parms.schema.schemaOnCE = "\\UltraLite\\tutorial\\tutcustomer.usm"";
The new parameters are schemaOnCE and databaseOnCE. They indicate where on the device the schema and database are to be deployed.
Compile your application again.
Run your application to check that no errors were introduced. The schemaOnCE and databaseOnCE parameters have no effect when running in a desktop environment.
Prepare a shortcut to run the application.
A shortcut is a text file with .lnk extension, which contains a command line to run the application. In the next procedure, you copy this shortcut file to a location on the device.
Using a text editor, create a file named tutorial.lnk in your tutorial directory with the following content, which should all be on a single line.
18#"\Windows\evm.exe" -Djeode.evm.console.local.keep=TRUE -Djeode.evm.console.local.paging=TRUE -Djul.library.dir=\UltraLite\lib -cp \UltraLite\tutorial;\UltraLite\lib\jul9.jar Customer
The content is displayed on multiple lines for legibility. The meaning of the elements in this command are as follows:
The first line starts the Jeode VM executable.
The -Djeode
options control the display of the text console that is used for output from the application.
The -Djul.library.dir
option directs the VM to the UltraLite native interface runtime library (jul9.dll)
The -cp
option provides the classpath for the VM. It indicates the location of the application and the UltraLite runtime library.
The final argument is the class, which in this case is Customer
.
You are now ready to copy the files to your device. You must copy both UltraLite runtime files and application-specific files.
To deploy the UltraLite runtime to the Windows CE device
Start Windows Explorer on your Windows CE device.
Ensure that your device is connected to your desktop computer.
In the ActiveSync window, click Explore. An Explorer window opens.
Create directories to hold the UltraLite runtime and application.
In the Explorer window, click My Pocket PC to access the root directory.
Create a directory named UltraLite.
Open the UltraLite directory and create subdirectories named lib and tutorial. The directory path \UltraLite\lib is the location for the UltraLite runtime files, and the path \UltraLite\tutorial is the location for the application. These directories match the options in the shortcut file described above.
Copy the UltraLite runtime files to the Windows CE device:
Start a separate Explorer window and navigate to the SQL Anywhere installation directory on our desktop machine.
Drag the following files from the desktop to the device
Desktop location relative to your SQL Anywhere directory | Windows CE location |
---|---|
UltraLite\NativeUltraLiteForJava \jul9.jar | \UltraLite\lib\jul9.jar |
UltraLite\NativeUltraLiteForJava \ce\arm\jul9.dll | \UltraLite\lib\jul9.dll |
Copy the application files to the Windows CE device:
In your Explorer window, navigate to the tutorial directory.
Drag the following files from the desktop to the device
Desktop location | Windows CE location |
---|---|
Customer.class |
\UltraLite\tutorial |
tutcustomer.usm | \UltraLite\tutorial |
In this tutorial, do not copy the database file to the Windows CE device.
Copy the shortcut file to the Windows CE device:
Drag the following file from the desktop to the device
Desktop location | Windows CE location |
---|---|
tutorial.lnk | \Windows\Start Menu |
You are now ready to run the application on your Windows CE device.
To run the application
On the Windows CE device, choose Start
This shortcut is the tutorial.lnk file that you copied onto the device.
The Jeode VM loads and the console is displayed.
The following messages are printed onto the console:
Connected to a new database. Two rows inserted. id= 1, name= Gene Poole id= 2, name= Penny Stamp Application finished. Please close console
Close the console.
On the Windows CE device, choose Start
This time the first two messages are as follows:
Connected to an existing database. The table has 2 rows.
Close the console.
You have now written an application, tested it on a desktop computer, and deployed it to a Windows CE device.