Select which mode to use when running a Java program

When you run a Java™ program, you can select which mode you would like to use. All modes verify the code and create a Java program object to hold the preverified form of the program.

You can use any of the following modes:

Selection mode Details
Interpreted

Each bytecode is interpreted at runtime.

For information on running your Java program in the interpreted mode, see the Run Java (RUNJVA) command.

Direct Processing

Machine instructions for a method are generated during the first call to that method, and saved for use the next time that the program runs. One copy is also shared for the entire system.

For information on running your Java program using direct processing, see the Run Java (RUNJVA) command.

Just-In-Time (JIT) compile

i5/OS™ interprets Java methods until reaching the threshold specified by the os400.jit.mmi.threshold Java system property. After reaching the threshold, i5/OS uses the JIT compiler to compile methods into native machine instructions.

To use the Just-In-Time compiler, you need to set the compiler value to jitc. You can set the value by adding an environment variable or setting the java.compiler system property. Select one method from the list below to set the compiler value:

  • From a command line prompt on your iSeries™ server, add the environment variable by using the Add Environment Variable (ADDENVVAR) command. Then, run your Java program using the Run Java (RUNJVA) command or JAVA command. For example, use:
    ADDENVVAR ENVVAR (JAVA_COMPILER) VALUE(jitc)
    JAVA CLASS(Test)
  • Set the java.compiler system property on the iSeries command line. For example, enter JAVA CLASS(Test) PROP((java.compiler jitc))
  • Set the java.compiler system property on the Qshell Interpreter command line. For example, enter java -Djava.compiler=jitc Test
Once you set this value, the JIT compiler optimizes all of the Java code before running it.
Just-In-Time (JIT) compile and Direct Processing

The most common way to use the Just-In-Time (JIT) compiler is with the jit_de option. When running with this option, programs that have already been optimized with direct processing run in direct processing mode. Programs that have not been optimized for direct optimization run in JIT mode.

To use JIT and direct processing together, you need to set the compiler value to jitc_de. You can set the value by adding an environment variable or setting the java.compiler system property. Select one method from the following list to set the compiler value:

  • Add the environment variable by entering the Add Environment Variable (ADDENVVAR) command on the iSeries command line. Then, run your Java program using the Run Java (RUNJVA) command or JAVA command. For example, enter
    ADDENVVAR ENVVAR (JAVA_COMPILER) VALUE(jitc_de)
    JAVA CLASS(Test)
  • Set the java.compiler system property on the iSeries command line. For example, enter JAVA CLASS(Test) PROP((java.compiler jitc_de))
  • Set the java.compiler system property on the Qshell Interpreter command line. For example, enter java -Djava.compiler=jitc_de Test
Once this value is set, the Java program for the class file that was created as direct processing is used. If the Java program was not created as direct processing, the class file is optimized by the JIT prior to running. For more information, see Comparison of Just-In-Time compiler and direct processing

There are three ways that you can run a Java program (CL, QSH, and JNI). Each has a unique way to specify the mode. This table shows how that is done.

Mode CL Command QShell Command JNI Invocation API
Interpret INTERPRET(*YES) -Djava.compiler=NONE -interpret os400.run.mode=interpret
DE INTERPRET(*NO) -Djava.compiler=NONE
  • os400.run.mode= program_created=pc
  • os400.create.type= direct
JIT INTERPRET(*JIT) -Djava.compiler=jitc os400.run.mode=jitc
JIT_DE(default) INTERPRET(*OPTIMIZE) OPTIMIZE(*JIT) -Djava.compiler=jitc_de os400.run.mode=jitc_de