Show TOC

Background documentationStandard Options Locate this document in the navigation structure

 

The following standard-options are available.

  • -classpath <classpath>, -cp <classpath>

    Specify a list of directories, JAR archives, and ZIP archives to search for class files. Class path entries are separated by semicolons (;) on Windows and colons (:) on other platforms respectively. Specifying -classpath or -cp overrides any setting of the CLASSPATH environment variable.

    If -classpath and -cp are not used and CLASSPATH is not set, the user class path consists of the current directory (.).

  • -D<property>=<value>

    Set a system property value. If >value> is a string that contains spaces, you must enclose the string in double quotes:

    Example Example

    java -Dfoo="some string" SomeClass

    End of the example.
  • -enableassertions[:<package>”...”|:<class>], -ea[:<package>”...”|:<class>]

    Enable assertions. Assertions are disabled by default.

    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, they 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[:<package>”...”|:<class>], -da[:<package>”...”|:<class>]

    Disable assertions. This is the default.

    With no arguments, -disableassertions or -dadisables 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. A separate switch is provided to enable asserts in all system classes; see -disablesystemassertions below.

  • -enablesystemassertions

    -esa

    Enable asserts in all system classes (sets the default assertion status for system classes to true).

  • -disablesystemassertions

    -dsa

    Disables asserts in all system classes.

  • -jar

    Execute a program encapsulated in a JAR file. 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: <class>. Here, <class> identifies the class having the public static void main(String[] args) method that serves as your application's starting point.

    When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

  • -verbose

    -verbose:class

    Display information about each class loaded.

  • -verbose:gc

    Report on each garbage collection event.

  • -verbose:jni

    Report information about use of native methods and other Java Native Interface activity.

  • -version

    Display version information and exit.

  • -showversion

    Display version information and continue.

  • -fullversion

    Display full product version information and exit.

  • -agentlib:<libname>[=<options>]

    Load the native agent library <libname>, e.g. -agentlib:hprof

    See also, -agentlib:jdwp=help and -agentlib:hprof=help

  • -agentpath:<pathname>[=<options>]

    Load the native agent library by full pathname.

  • -javaagent:<jarpath>[=<options>]

    Load a Java programming language agent, see documentation of package java.lang.instrument

  • -splash:<imagepath>

    Show a splash screen containing the specified image and continue.

  • -help

    Display usage information and exit.

  • -X

    Display information about non-standard options and exit.

More Information

Non-standard Options