Specifying command-line options

Although the command line is the traditional way to specify command-line options, you can also pass options to the Java™ virtual machine (VM) by using a manifest file, options files, and environment variables.

The sequence of the Java options on the command line defines which options take precedence during startup. Rightmost options have precedence over leftmost options. In the following example, the -Xjit option takes precedence:
java -Xint -Xjit myClass

Use single or double quotation marks for command-line options only when explicitly directed to do so. Single and double quotation marks have different meanings on different platforms, operating systems, and shells. Do not use '-X<option>' or "-X<option>". Instead, you must use -X<option>. For example, do not use '-Xmx500m' and "-Xmx500m". Write this option as -Xmx500m.

At startup, the list of VM arguments is constructed in the following order, with the lowest precedence first:
  1. Certain options are created automatically by the VM, which specify arguments such as search paths and version information. The VM automatically adds -Xoptionsfile=<vm_dir>/options.default at the beginning of the command line, where <vm_dir> is the virtual machine directory. This directory is as follows:
    • install_dir/lib/<arch>/default
    If you are using compressed references, <vm_dir> points to the compressedrefs subdirectory, not the default subdirectory on the same path.

    You can modify the options.default file to include any options that you want to specify for your application instead of entering these options on the command line. For more information about the construction of the file, see -Xoptionsfile.

  2. Start of changes for service refresh 4 fix pack 5

    Options can be specified in an executable JAR file by using the META-INF/MANIFEST.MF file. Options are placed in the main section in a header named IBM-Java-Options. Only one IBM-Java-Options header is permitted, but the header can contain multiple options, separated by spaces. A long sequence of options can be split using a header continuation but are treated as a single line.

    Example manifest file:
    Manifest-Version: 1.0
    Class-Path: .
    Main-Class: HelloWorld
    IBM-Java-Options: -Xshareclasses:name=mycache,nonfa
     tal,cacheDirPerm=1000 -Dproperty=example -Da.long.system.pro
     perty="this is a long system property value to
      demonstrate long JVM arguments
     in the manifest file"
    This example manifest file is parsed as the following string:
    -Xshareclasses:name=mycache,nonfatal,cacheDirPerm=1000
    -Dproperty=example
    -Da.long.system.property=this is a long system property value to
    demonstrate long JVM arguments in the manifest file
    Options specified in the manifest file are subject to the same restrictions as options files. For more information, see the -Xoptionsfile topic in the user guide.End of changes for service refresh 4 fix pack 5
  3. Environment variables that are described in J9 environment variables are translated into command-line options. For example, the following environment variable adds the parameter -Xrs to the list of arguments:
    • export IBM_NOSIGHANDLER=<non_null_string>
  4. The IBM_JAVA_OPTIONS environment variable. You can set command-line options using this environment variable. The options that you specify with this environment variable are added to the command line when a JVM starts in that environment.
    The environment variable can contain multiple blank-delimited argument strings, but must not contain comments. For example:
    • export IBM_JAVA_OPTIONS="-Dmysysprop1=tcpip -Dmysysprop2=wait -Xdisablejavadump"
    Note: The environment variable JAVA_TOOLS_OPTIONS is equivalent to IBM_JAVA_OPTIONS and is available for compatibility with JVMTI.
  5. Options that are specified on the command line. For example:
    java -Dmysysprop1=tcpip -Dmysysprop2=wait -Xdisablejavadump MyJavaClass

    The Java launcher adds some automatically generated arguments to this list, such as the names of the main class.

You can also use the -Xoptionsfile parameter to specify JVM options. This parameter can be used on the command line, or as part of the IBM_JAVA_OPTIONS environment variable. The contents of an option file are expanded in place during startup. For more information about the structure and contents of this type of file, see -Xoptionsfile.
To troubleshoot startup problems, you can check which options are used by a JVM. Append the following command-line option, and inspect the Java core file that is generated:
-Xdump:java:events=vmstart
Here is an extract from a Java core file that shows the options that are used:
....
    2CIUSERARG               -Xdump:java:file=/home/test_javacore.txt,events=vmstop
    2CIUSERARG               -Dtest.cmdlineOption=1
    2CIUSERARG               -XXallowvmshutdown:true
    2CIUSERARG               -Xoptionsfile=test1.test_options_file
....