Using the AOT compiler

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
  1. 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.
  2. Package the class files generated into a jar file. For example, to create test.jar:
    jar cvf test.jar source
  3. 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.
  4. From a shell prompt, enter:
    java -Xrealtime -Xnojit ./aot/test.jar test.jar
    This command runs the precompiled file.


© Copyright IBM Corporation 2005, 2010. All Rights Reserved.
© Copyright Sun Microsystems, Inc. 1997, 2007, 901 San Antonio Rd., Palo Alto, CA 94303 USA. All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
This information center is powered by Eclipse technology. (http://www.eclipse.org/)