Use these steps to precompile your Java™ code. This procedure describes the use
of the -Xrealtime option in a javac command,
the tool,
and the -Xrealtime and -Xnojit options
with the java command.
About this task
Using the ahead-of-time compiler means that compilation
is separate from the run time of the application. Also, you can compile
more methods at the same time rather than just the frequently used
methods. You can compile everything in an application or just individual
classes, as shown in the following steps.
Note: When using shared class
caches, the name of the cache must not exceed 53 characters.
Procedure
- From a shell prompt, enter:
javac -Xrealtime source
This
command creates the Java bytecode
from your source for use in the real-time environment. See Figure 1.
- Package the class files generated into a jar file. For
example, to create test.jar:
jar cvf test.jar source
- From a shell prompt, enter:
admincache -Xgcpolicy:metronome -populate -aot test.jar -cacheName myCache -cp test.jar
Alternatively, the
jxeinjar command
is compatible with previous versions:
jxeinajar -Xrealtime -outPath ./aot test.jar
This
command precompiles the test.jar file and writes the output
to the output directory ./aot.
- From a shell prompt, enter:
java -Xrealtime -Xnojit ./aot/test.jar test.jar
This
command runs the precompiled file.