Virtual machine startup practices can vary significantly in different KVM ports. By default, KVM supports regular command line based Java virtual machine startup, but the virtual machine can easily be modified for those environments in which command line based startup is not desired.
This subsection describes the virtual machine startup conventions when launching KVM from a command line.
The file VmExtra/src/main.c
provides a default implementation of main()
. The virtual machine is called from the command line as follows:
where each option
is one of
The required className
argument specifies the class whose method static main(String argv[])
is to be called. All arguments beyond the class name are uninterpreted strings that are made into a single String[]
object and passed as the single argument to the main
method.
The -
classpath option allows the user to define the directories from which the KVM reads the class files. The parameter <list
of
directories>
is a single string in which the directories are separated by the PATH_SEPARATOR
character. The value of the PATH_SEPARATOR
character is typically ‘;’ on Windows platforms, and ‘:’ on Unix platforms.
The -heapsize
option (introduced in KVM 1.0.3) allows the user to manually set the Java heap size that KVM allocates upon virtual machine startup. The heap size can range from 16 kilobytes to 64 megabytes. The heap size can be specified either in bytes (such as 32768), kilobytes (such as 32k or 32K), or megabytes (such as 1m or 1M). Note that when the heap size is defined in bytes, the KVM automatically rounds up the heap size number to the next number that is divisible by four.
Additionally, if the virtual machine has been compiled with the INCLUDEDEBUGCODE
mode turned on, the tracing options given in TABLE 6 are available.
When the Java-level debugging interface is in use, additional command line options are available to control the debugger. Refer to Chapter 16 for details.
The default implementation of main(int argc,
char
**argv)
calls the function StartJVM()
with an argv
in which all of the options have been removed and an argc
that has been decremented appropriately.
If your implementation does not start the virtual machine from a command line (for example, if you use a graphical environment for application launching), you must arrange your code to call StartJVM()
with the appropriate arguments.
Many KVM ports run on resource-constrained devices which lack many features commonly available in desktop operating systems, such as a command line language, graphical file manager, or even a file system. To facilitate the porting of KVM to such platforms, KVM provides a sample implementation of a facility called JAM (Java Application Manager).
At the compilation level, JAM can be turned on or off by using the flag
When building the KVM using gnumake, the following command automatically builds the system with the JAM enabled:
If JAM is compiled into the KVM, it must be activated with the -jam
command line flag.
The JAM implementation assumes that applications are available for downloading as JAR files by using the HTTP protocol. The JAM reads the contents of the JAR file and an associated descriptor file via HTTP, and launches KVM with the main class as a parameter.
Since the JAM serves as an interface between the host operating system and the virtual machine, it can be used, e.g., as a starting point for a device-specific graphical Java application management and launching environment (“microbrowser”), or as a test harness for virtual machine testing. The JAM reference implementation provides a special “-repeat” mode that allows the JAM to run a large number of Java applications (e.g., test cases) without having to restart the virtual machine every time.
Refer to Chapter 15, "Java Application Manager (JAM),” for further information on the JAM.
KVM Porting Guide , CLDC 1.1 |
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.