Run Java Program (RUNJVA)

Where allowed to run: All environments (*ALL)
Threadsafe: No
Parameters
Examples
Error messages

The Run Java Program (JAVA) command runs the Java program associated with the specified Java class. If no Java program exists, one is created and associated with the class file.

This command can operate on files in any file system that supports the integrated file system APIs.

Top

Parameters

Keyword Description Choices Notes
CLASS Class file or JAR file Path name, *VERSION Required, Positional 1
PARM Parameters Single values: *NONE
Other values (up to 200 repetitions): Character value
Optional, Positional 2
CLASSPATH Classpath Path name, *ENVVAR Optional
CHKPATH Classpath security check level *WARN, *SECURE, *IGNORE Optional
OPTIMIZE Optimization *JIT, *INTERPRET, 10, 20, 30, 40 Optional
INTERPRET Interpret *OPTIMIZE, *YES, *NO, *JIT Optional
PROP Properties Single values: *NONE
Other values (up to 200 repetitions): Element list
Optional
Element 1: Property name Path name
Element 2: Property value Character value, *NONE
GCHINL Garbage collect initial size 256-240000000, *DFT Optional
GCHMAX Garbage collect maximum size 256-240000000, *DFT, *NOMAX Optional
GCFRQ Garbage collection frequency 0-100, 50 Optional
GCPTY Garbage collection priority 20, 10, 30 Optional
OPTION Option Values (up to 4 repetitions): *NONE, *VERBOSE, *DEBUG, *VERBOSEGC, *NOCLASSGC Optional
JOB Job name Name, QJVACMDSRV, *GEN Optional
AGTPGM Agent program Single values: *NONE
Other values: Qualified object name
Optional
Qualifier 1: Agent program Name
Qualifier 2: Library Name, *LIBL, *CURLIB
AGTOPTIONS Agent options Character value, *NONE Optional
OUTPUT Output Single values: *PRINT, *NONE
Other values: Element list
Optional
Element 1: Destination *
Element 2: Program end action *PAUSE, *CONTINUE
Top

Class file or JAR file (CLASS)

Specifies the class name or jar file to be run. The class name may be qualified by one or more package names. Each package name must be followed by a period. For example, CLASS('pkg1.pkg2.myclass') identifies a class qualified by two package names.

A jar file name may be specified only when running JDK 1.2 or higher. The start up class must be indicated by the Main-Class in the manifest header.

class-name
Specify the name of the class to be run.
jar-name
Specify the name of the jar file with the Main-Class specified in the manifest.
*VERSION
The build version information for the Java Development Kit (JDK) and the Java Virtual Machine (JVM) is displayed. No Java program is run.
Top

Parameters (PARM)

Specifies one or more parameter values that are passed to the Java program. A maximum of 200 parameter values can be passed.

*NONE
There are no input parameters to the Java program.
parameter-value
Specify the parameter value to be passed to the Java program.
Top

Classpath (CLASSPATH)

Specifies the path used to locate classes. Directories are separated by colons.

*ENVVAR
The class path is determined by the environment variable CLASSPATH.
class-path
Path used to locate classes. An example class path is '/directory1/directory2:/QIBM/ProdData/Java400'.
Top

Classpath security check level (CHKPATH)

Specifies the level of warnings given for directories in the CLASSPATH that have public write authority. A directory in the CLASSPATH that has public write authority is a security exposure because it may contain a class file with the same name as the one you want to run. Whichever class file is found first is run.

*WARN
A warning message is sent for each directory in the CLASSPATH that has public write authority.
*SECURE
A warning message is sent for each directory in the CLASSPATH that has public write authority. If one or more warning messages are sent, an escape message is sent and the Java program is not run.
*IGNORE
Ignore the fact that directories in the CLASSPATH may have public write authority. No warnings messages are sent.
Top

Optimization (OPTIMIZE)

Specifies how to treat class files if no Java program is associated with the file, or if the associated Java program is not up to date with the contents of the class file.

Beginning with Version 5 Release 5 Modification 0, Java programs do not contain machine instructions. Therefore values 10, 20, 30 and 40 are no longer supported. The value OPTIMIZE(*JIT) will be used instead.

*JIT
The Java program created does not contain machine instructions. The class is run using the Just In Time compiler (JIT).
*INTERPRET
The Java program created does not contain machine instructions. If the INTERPRET(*OPTIMIZE) parameter is also specified, all of the classes that run will be interpreted.
10, 20, 30, 40
These parameter values are no longer supported and only exist for compatibility with releases prior to V5R5M0. The value OPTIMIZE(*JIT) is used instead.
Top

Interpret (INTERPRET)

Specifies how the Java class files should be run.

*OPTIMIZE
Whether all Java classes are run interpretively depends on the value specified for the OPTIMIZE parameter. If OPTIMIZE(*INTERPRET) was specified, all Java classes will be run interpretively. If any other value was specified for the OPTIMIZE parameter, all Java class files will be run using the Just In Time compiler.
*YES
All Java classes will be run interpretively.
*NO
This value exists only to maintain compatibility with releases prior to V5R5M0. The value INTERPRET(*JIT) is used instead.
*JIT
All Java class files will be run using the Just In Time compiler (JIT), regardless of what OPTIMIZE value was used when the associated Java program was created.
Top

Properties (PROP)

Specifies a list of values to assign to Java properties. Up to 200 properties can have a value assigned.

Single values

*NONE
No properties are specified.

Element 1: Property name

property-name
Specify the name of the property to be changed.

Element 2: Property value

property-value
Specify the value to be assigned to the property.
Top

Garbage collect initial size (GCHINL)

Specifies the initial size, in kilobytes, of the garbage collection heap. This is used to prevent garbage collection from starting on small programs.

*DFT
The default initial size is 16384 kilobytes unless it is overridden by a property.
256-240000000
Specify the initial size, in kilobytes, of the garbage collection heap. It is recommended that the initial heap size be set to 16384 kilobytes (the default) or larger.
Top

Garbage collect maximum size (GCHMAX)

Specifies the maximum size, in kilobytes, that the garbage collection heap can grow to. This is used to prevent runaway programs that consume all of the available storage. Normally, garbage collection runs as an asynchronous thread in parallel with other threads. If the maximum size is reached, all other threads are stopped while garbage collection takes place. This may adversely affect performance.

*DFT
The default for the parameter is used. The default maximum is determined by the system unless a property is specified. The heap will grow until all system resources are depleted. Then a synchronous garbage collection is started to reclaim resources no longer in use.
*NOMAX
The maximum size is not specified by the user. The maximum is determined by the system. The heap will grow until all system resources are depleted. Then a synchronous garbage collection is started to reclaim resources no longer in use.
256-240000000
Specify the size, in kilobytes, that the garbage collection heap can grow to.
Top

Garbage collection frequency (GCFRQ)

Specifies the relative frequency that garbage collection runs.

This parameter is no longer supported. It exists solely for compatibility with the releases earlier than Version 4 Release 3 Modification 0.

Top

Garbage collection priority (GCPTY)

Specifies the priority of the tasks running garbage collection.

This parameter is no longer supported. It exists solely for compatibility with the releases earlier than Version 4 Release 3 Modification 0.

Top

Option (OPTION)

Specifies special options used when running the Java class.

*NONE
No special options are used when running the Java class.
*VERBOSE
A message is displayed each time a class file is loaded.
*DEBUG
Allows the system debugger to be used for this Java program. This value cannot be used with the JIT compiler. That is, *DEBUG is mutually exclusive with INTERPRET(*JIT). Also, *DEBUG cannot be used when a JAR file is specified for the CLASS keyword.
*VERBOSEGC
A message is displayed for each garbage collection sweep.
*NOCLASSGC
Unused classes are not reclaimed when garbage collection is run.
Top

Job name (JOB)

Specifies the name that is associated with the batch immediate (BCI) job that is started when this command is run. The BCI job is where the Java program will be run.

QJVACMDSRV
The job name for the BCI job will be QJVACMDSRV.
*GEN
The job name is generated from the class name.
name
Specify the name to be used for the BCI job that is used to run the Java program.
Top

Agent program (AGTPGM)

Specifies an ILE service program or i5/OS PASE program that contains a virtual machine (VM) agent. For example, a VM agent can be a remote debugger or profiler. The VM loads the agent program and looks for the entry point:

jint JNICALL JVM_OnLoad(JavaVM *jvm, char *options, void *reserved);

The VM calls the JVM_OnLoad function, passing a pointer to the JavaVM instance as the first argument, and the character string specified in the AGTOPTIONS parameter as the second argument. The third argument to JVM_OnLoad is reserved and set to NULL.

Single values

*NONE
No VM agent program is specified.

Qualifier 1: Agent program

name
Specify the name of the VM agent program.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found. If the VM agent is an i5/OS PASE program, the directories contained in the LIBPATH and PASE_LIBPATH environment variables are used to locate the program.
*CURLIB
The current library for the thread is searched. If no library is specified as the current library for the thread, the QGPL library is searched.
name
Specify the name of the library to be searched.
Top

Agent options (AGTOPTIONS)

Specifies a character string of the virtual machine (VM) agent options. A pointer to this character string will be passed as the second argument to the JVM_OnLoad function in the VM agent program specified in the AGTPGM parameter. The format of the options string is determined by the agent program.

*NONE
No options are specified. A NULL options argument will be passed to the JVM_OnLoad function.
character-value
Specify the options string to be passed to the VM agent program on start-up.
Top

Output (OUTPUT)

Specifies where output from the Java program should be sent and, if output is directed to the Java shell display, whether the shell display panel should go away when the Java program ends.

Single values

*PRINT
The Java program output is sent to a spooled file through the QPRINT printer device file.
*NONE
The Java program output is discarded.

Element 1: Destination

*
A Java shell display panel will be used to display output if the Java program is run from an interactive job. If the Java program is run in a batch job, the Java program output is sent to a spooled file through the QPRINT printer device file.

Element 2: Program end action

*PAUSE
The Java shell display panel is shown until the F3, F12, or Enter key is pressed.
*CONTINUE
The Java shell display panel is closed (goes away) when the Java program ends.
Top

Examples

Example 1: Run a Java Program

JAVA   CLASS('projectA.myJavaclassname')

This command will run the i5/OS Java program associated with the class myJavaclassname. The job name of the batch immediate (BCI) job where the Java program will run will be QJVACMDSRV.

Example 2: Generate the Job Name for the Java Program

JAVA   CLASS('projectA.myJavaclassname') JOB(*GEN)

This command will run the i5/OS Java program associated with the class myJavaclassname. The job name of the batch immediate (BCI) job where the Java program will run will be MYJAVACLAS.

Top

Error messages

*ESCAPE Messages

JVAB534
Unable to complete Java program "&1".
JVAB535
Unmonitored exception received.
JVAB537
Java shell already active in job.
JVAB538
Error occurred when running Java shell.
JVAB539
Unable to start system debugger.
JVAB53A
Unable to start Java shell, reason code &1.
JVAB53B
Java processing canceled.
JVAB53D
Java Development Kit could not be found.
JVAB546
Error detected while running java in batch mode.
Top