System debugging for IBM Technology for Java
These instructions present several options for debugging IBM® Technology for Java™ JVMs.
Interactive debugging from the CL command line
> JAVA CLASS(Hello) OPTION(*DEBUG)
Enabling debug for the IBM Technology for Java JVM
- The debug agent does not suspend the JVM prior to entering the main method. For short-running programs or for debugging the main method, additional Java code may be needed in order to stop the JVM. One way to do this is with a timed wait-loop. Another way is to read from standard input.
- If debug is attempted on a JVM which does not have the debug agent enabled, a JVAB307 diagnostic message is sent to the job log of both the JVM job and the servicing job. The message text identifies the JVM job that does not have debug enabled. This message indicates that the JVM must be restarted in order to be successfully debugged. It is not possible to enable debug after the JVM is started.
Enabling Java debug from CL
> JAVA CLASS(Hello) AGTPGM(D9TI)
Enabling Java debug from Qshell or the PASE terminal
> java -debug Hello
Using
the -debug parameter is a simplest way to start the debug
agent. It is the same as adding the -agentlib:d9ti parameter.
The following will also start the debug agent:> java -agentlib:d9ti Hello
Enabling Java debug for a batch job JVM
> SBMJOB CMD(JAVA CLASS(HELLO) AGTPGM(D9TI))
CPYENVVAR(*YES) ALWMLTTHD(*YES)
If the batch job
is started in some other way, then the JAVA_TOOL_OPTIONS environment
variable may be used to start the debug agent. The JAVA_TOOL_OPTIONS
environment variable is automatically queried by the JVM during startup.
If it is set to -debug or -agentlib:d9ti, then the debug
agent will be started for the JVM. For example, one of the following
may be used to set the environment variable:> ADDENVVAR ENVVAR(JAVA_TOOL_OPTIONS) VALUE('-debug')
> ADDENVVAR ENVVAR(JAVA_TOOL_OPTIONS) VALUE('-agentlib:d9ti')
If
the batch job does not automatically inherit all environment variables,
then the JAVA_TOOL_OPTIONS environment variable will need to be set
system-wide. For example:> ADDENVVAR ENVVAR(JAVA_TOOL_OPTIONS) VALUE('-debug') LEVEL(*SYS)
Enabling Java debug for a JVM created with the Java Invocation API
- Set the JAVA_TOOL_OPTIONS environment variable to -debug.
- Set the JAVA_TOOL_OPTIONS environment variable to -agentlib:d9ti.
- Add the -debug parameter to the options parameter list passed to the JNI_CreateJavaVM API.
- Add the -agentlib:d9ti parameter to the options parameter list passed to the JNI_CreateJavaVM API.
- Add "-debug" or "-agentlib:d9ti" to the QIBM_RPG_JAVA_OPTIONS environment variable if you are starting the JVM by calling a Java method from RPG.
Debugging must be done from another job.
In addition, in order to see the Java source code for the classes being debugged, the DEBUGSOURCEPATH environment variable may need to be set to the base directory location of the Java source code.
Starting the IBM Technology for Java JVM from the IBM i Debugger graphical user interface
In order to start an IBM Technology for Java JVM from the IBM i Debugger graphical user interface, the JAVA_HOME environment variable must be set when starting the JVM job. You can set this environment variable using the Initialization Command display when starting the JVM. This display is located in the Start Debug window of the IBM i Debugger interface.
ADDENVVAR ENVVAR(JAVA_HOME) VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit')