Java args

STANDARD OPTIONS

-classpath (or -cp)
- Specifies a list of directories, JAR archives, and ZIP archives to search for class files. Class path entries are separated by colons (:). Specifying this overrides any setting of the CLASSPATH environment variable.

-Dproperty=value - Sets a system property value. Example: -Dsun.rmi.dgc.server.gcInterval=0x36EE80

-enableassertions (or -ea) - Enables assertions. Assertions are disabled by default. You can limit it to specific packages and classes:

-enableassertions:package-name "..."
-enableassertions:class-name

(Note on enableassertions: With no arguments, -enableassertions or -ea enables assertions. With one argument ending in "...", the switch enables assertions in the specified package and any subpackages. If the argument is simply "...", the switch enables assertions in the unnamed package in the current working directory. With one argument not ending in "...", the switch enables assertions in the specified class. If a single command line contains multiple instances of these switches, the are processed in order before loading any classes. So, for example, to run a program with assertions enabled only in package com.wombat.fruitbat (and any subpackages), the following command could be used:

java -ea:com.wombat.fruitbat... main_class

The -enableassertions and -ea switches apply to all class loaders and to system classes (which do not have a class loader). There is one exception to this rule: in their no-argument form, the switches do not apply to system. This makes it easy to turn on asserts in all classes except for system classes. A separate switch is provided to enable asserts in all system classes. See -enablesystemassertions below.)

-disableassertions (or -da) - Disables assertions. This is the default. You can limit it to specific packages and classes:

-disableassertions:package-name "..."
-disableassertions:class-name

(Note on disableassertions: With no arguments, -disableassertions or -da disables assertions. With one argument ending in "...", the switch disables assertions in the specified package and any subpackages. If the argument is simply "...", the switch disables assertions in the unnamed package in the current working directory. With one argument not ending in "...", the switch disables assertions in the specified class. To run a program with assertions enabled in package com.wombat.fruitbat but disabled in class com.wombat.fruitbat.Brickbat, the following command could be used:

java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat main_class

The -disableassertions and -da switches apply to all class loaders and to system classes (which do not have a class loader). There is one exception to this rule: in their no-argument form, the switches do not apply to system. This makes it easy to turn off asserts in all classes except for system classes. A separate switch is provided to disable asserts in all system classes. See -disablesystemassertions below.)

-enablesystemassertions (or -esa) - Enables asserts in all system classes (sets the default assertion status for system classes to true).

-disablesystemassertions (or -dsa) - Disables asserts in all system classes.

-jar - Executes a program encapsulated in a JAR archive. The first argument is the name of a JAR file instead of a startup class name. In order for this option to work, the manifest of the JAR file must contain a line of the form Main-Class:classname. Here, classname identifies the class having the public static void main(String[] args) method that serves as your application's starting point. See the Jar tool reference page and the Jar trail of the Java Tutorial for information about working with Jar files and Jar-file manifests. When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

-verbose - provides feedback information on its activity. In addition to the broad verbose, you can specify three specific areas:

-verbose:class - Displays information about each class loaded.
-verbose:gc - Reports on each garbage collection event.
-verbose:jni - Reports information about use of native methods and other Java Native Interface activity.

-showversion - Displays Java version information and continues.

NON-STANDARD OPTIONS (perhaps the X stands for eXtra options)

-Xint - Operates in interpreted-only mode. Compilation to native code is disabled, and all bytecodes are executed by the interpreter. The performance benefits offered by the Java HotSpot VMs' adaptive compiler will not be present in this mode.

-Xbatch - disable background compilation

-Xmixed - mixed mode execution (both interpreted and compiled mode where appropriate) This is the default.

-Xbootclasspath:bootclasspath - Specifies a colon-separated list of directories, JAR archives, and ZIP archives to search for boot class files. These are used in place of the boot class files included in the Java 2 SDK and Java 2 Runtime Environment.

-Xbootclasspath/a:path - Specifies a colon-separated path of directories, JAR archives, and ZIP archives to append to the default bootstrap class path.

-Xbootclasspath/p:path - Specifies a colon-separated path of directories, JAR archives, and ZIP archives to prepend in front of the default bootstrap class path. Note: Applications that use this option for the purpose of overriding a class in the default bootstrap class path should not be deployed, as doing so would contravene the Java 2 Runtime Environment binary code license.

-Xdebug - Starts with the debugger enabled. Here's a writeup on how to use it: http://java.sun.com/j2se/1.3/docs/tooldocs/win32/jdb.html

-Xfuture- Performs strict class-file format checks. For purposes of backwards compatibility, the default format checks performed by the Java 2 SDK's virtual machine are no stricter than the checks performed by 1.1.x versions of the JDK software. The -Xfuture flag turns on stricter class-file format checks that enforce closer conformance to the class-file format specification. Developers are encouraged to use this flag when developing new code because the stricter checks will become the default in future releases of the Java application launcher.

-Xincgc - enable incremental garbage collection.

-Xnoclassgc - Disables class garbage collection

-Xms# (where # is a number) - Specifies the initial size of the memory allocation pool. This value must be greater than 1000. To modify the meaning of n, append either the letter k for kilobytes or the letter m for megabytes.

-Xmx# (where # is a number)- Specifies the maximum size of the memory allocation pool. This value must be greater than 1000. To modify the meaning of n, append either the letter k for kilobytes or the letter m for megabytes.

-Xss# (where # is a number) - Each Java thread has two stacks: one for Java code and one for C code. The -Xss option sets the maximum stack size that can be used by C code in a thread to n. Every thread that is spawned during the execution of the program passed to java has n as its C stack size. The default units for n are bytes and n must be > 1000 bytes. To modify the meaning of n, append either the letter k for kilobytes or the letter m for megabytes.

-Xcheck:jni - perform additional checks for JNI functions

-Xprof - Profiles the running program, and sends profiling data to standard output. This option is provided as a utility that is useful in program development and is not intended to be be used in production systems.

-Xrunhprof[:help][:suboption=value,...] - Enables cpu, heap, or monitor profiling. This option is typically followed by a list of comma-separated suboption=value
pairs. Run the command java -Xrunhprof:help to obtain a list of suboptions and their default values.

Option Name and Value Description Default
heap=dump|sites|all heap profiling all
cpu=samples|times|old CPU usage off
format=a|b ascii or binary output a
file=<file> write date to file java.hprof(.txt for ascii)
net=<host>:<port> send data over a seocket write to file
depth=<size> stack trace depth 4
cutoff=<value> output cutoff point 0.0001
lineno=y|n line number in traces? y
thread=y|n thread in traces? n
doe=y|n dump on exit y
monitor=y|n monitor contention n

Example: java -Xrunhprof:cpu=samples,file=log.txt,depth=3 FooClass

-Xrs - Reduce usage of operating-system signals by Java virtual machine (JVM). The JVM catches signals to implement shutdown hooks for abnormal
JVM termination. The JVM uses SIGHUP, SIGINT, and SIGTERM to initiate the running of shutdown hooks. The JVM uses SIGQUIT to perform thread dumps. Applications that embed the JVM frequently need to trap signals like SIGINT or SIGTERM, and in such cases there is the possibil ity of interference between the applications' signal handlers and the JVM shutdown-hooks facility. To avoid such interference, the -Xrs option can be used to turn off the JVM shutdown-hooks feature. When -Xrs is used, the sig nal masks for SIGINT, SIGTERM, SIGHUP, and SIGQUIT are not changed by the JVM, and signal handlers for these signals are
not installed.