By default, classes are compiled
against the bootstrap and extension classes of the platform that javac
shipped with. But javac also supports cross-compiling, where classes are
compiled against a bootstrap and extension classes of a different Java
platform implementation. It is important to use -bootclasspath and -extdirs
when cross-compiling.
-target
<version>
Generate class files that will work on VMs with the specified version.
The default is to generate class files to
be compatible with both 1.1 VMs and VMs in the Java 2 SDK. The versions
supported by javac in the Java 2
SDK are:
1.1
Ensure that generated class files will be compatible with 1.1 and VMs in
the Java 2 SDK. This is the
default.
1.2
Generate class files that will run on VMs in the Java 2 SDK, v 1.2 and
later, but will not run on 1.1 VMs.
1.3
Generate class files that will run on VMs in the Java 2 SDK, v 1.3 and
later, but will not run on 1.1 or 1.2
VMs.
-bootclasspath
<bootclasspath>
Cross-compile against the specified set of boot classes. As with the user
class path, boot class path entries
are separated by colons (:) and can be directories, JAR archives, or ZIP
archives.
-extdirs
<directories>
Cross-compile against the specified extension directories. Directories
is a colon-separated list of directories.
Each JAR archive in the specified directories is searched for class files.
The SQLJ command line translator allows the user to specify these three options using the following -C syntax options:
% sqlj -vm=/usr/local/packages/jdk1.2.2/bin/java\In the command above, the SQLJ translator runs Java VM and Java compiler in SDK v1.2.2, with the runtime library in SDK v 1.3.1 as boot classes. The compiled code runs on SDK v 1.1.8. Using the SDK v 1.3.1. runtime library helps resolving some Java classes not existing in SDK v 1.2, for instance, javax.naming.Referenceable.
-compiler-executable=/usr/local/packages/jdk1.2.2/bin/javac\
-C-bootclasspath /usr/local/packages/jdk1.3.1/jre/lib/rt.jar \
-C-extdirs "" -C-target 1.1.8 Demo.sqlj
Note: The cross-compiler options can only be used when the SQLJ translator uses the Java compiler in Java 2 SDK v 1.2 or later. The Java compiler used by the SQLJ translator is determined by the system environment, e.g., the PATH enviroment in Solaris, or by the SQLJ -compiler-executable option.