Java Reference
In-Depth Information
The target option tells the compiler to produce bytecode compatible with a Java
version 1.1. With the J2SE 5.0 compiler, you must also add the option -source
1.3 to indicate that the code does not contain assertions and other post 1.3
additions. The bootclasspath option indicates that the core language classes
should be taken from the SNAP set of packages rather than from the standard
J2SE packages.
With J2SE the class files are loaded by the JVM, which first checks that the
bytecode conforms to all the standard specifications and doesn't do anything
illegal. The CLDC is intended for platforms with limited resources so it requires
that some of this bytecode checking is carried out prior to loading the processor.
The class files are run through a preverification program that checks the code and
creates new class files with annotations that the processor uses to accelerate its
own code checking.
So before the class files are moved to the SNAP, the following preverification
step is required:
c:\SNAP\bin\preverify -classpath c:\SNAP\classes;.
-nofinalize -d o HelloWorld
The -nofinalize flag is necessary because CLDC platforms don't allow for
invoking the finalize() method inherited from Object . The -d o flag sends
the verified class file to the o \ subdirectory.
Yo u can use ftp to place HelloWorld.class on the SNAP. To run the
program you can telnet into the Unix style command shell and run the program
with
> java -rHelloWorld &
which responds with the output
Hello World!
Here the -r flag tells the system to restart the Java processor in case it is still
running an old version of a class file. The & flag is not necessary here since the
program returns to the telnet prompt immediately after it prints the “ Hello
World! ” string. However, for a long-running program like a server, this flag
gives the console back to the shell in the normal Unix fashion so you can log off
while the process continues to run.
24.10.2 The web server program
The program below is a modified version of the MicroServer program
described in Chapter 14. The name is changed to SnapAdcServer since it
reads an ADC value if the page requested is adc.html . Otherwise, it acts as in
MicroServer and looks for files that are requested and returns them if found.
Search WWH ::




Custom Search