Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)
Arguments following the main class, source file, -jar <jarfile>,
-m or --module <module>/<mainclass> are passed as the arguments to
main class.
where options include:
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
--class-path <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-p <module path>
--module-path <module path>...
A : separated list of directories, each directory
is a directory of modules.
--upgrade-module-path <module path>...
A : separated list of directories, each directory
is a directory of modules that replace upgradeable
modules in the runtime image
--add-modules <module name>[,<module name>...]
root modules to resolve in addition to the initial module.
<module name> can also be ALL-DEFAULT, ALL-SYSTEM,
ALL-MODULE-PATH.
--list-modules
list observable modules and exit
-d <module name>
--describe-module <module name>
describe a module and exit
--dry-run create VM and load main class but do not execute main method.
The --dry-run option may be useful for validating the
command-line options such as the module system configuration.
--validate-modules
validate all modules and exit
The --validate-modules option may be useful for finding
conflicts and other errors with modules on the module path.
-D<name>=<value>
set a system property
-verbose:[class|module|gc|jni]
enable verbose output
-version print product version to the error stream and exit
--version print product version to the output stream and exit
-showversion print product version to the error stream and continue
--show-version
print product version to the output stream and continue
--show-module-resolution
show module resolution output during startup
-? -h -help
print this help message to the error stream
--help print this help message to the output stream
-X print help on extra options to the error stream
--help-extra print help on extra options to the output stream
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:jdwp
see also -agentlib:jdwp=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
HiDPI scaled images are automatically supported and used
if available. The unscaled image filename, e.g. image.ext,
should always be passed as the argument to the -splash option.
The most appropriate scaled image provided will be picked up
automatically.
See the SplashScreen API documentation for more information
@argument files
one or more argument files containing options
-disable-@files
prevent further argument file expansion
--enable-preview
allow classes to depend on preview features of this release
--custom-providers <provider>(,<provider>)
add configurations for custom providers
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.
Options (50)
| Option | Description | Source |
|---|---|---|
--list-modules | list observable modules and exit | help |
--dry-run | create VM and load main class but do not execute main method. | help |
--validate-modules | validate all modules and exit The --validate-modules option may be useful for finding conflicts and other errors with modules on the module path. | help |
-D name>=<value | set a system property | help |
-verbose class|module|gc|jni | enable verbose output | help |
-version | print product version to the error stream and exit | help + man |
--version | print product version to the output stream and exit | help |
-showversion | Displays version information and continues execution of the application. | help + man |
--show-version | print product version to the output stream and continue | help |
--show-module-resolution | show module resolution output during startup | help |
--help | print this help message to the output stream | help |
-X | print help on extra options to the error stream | help + man |
--help-extra | print help on extra options to the output stream | help |
-ea :<packagename>...|:<classname | help | |
-enableassertions :<packagename>...|:<classname | enable assertions with specified granularity | help |
-da :<packagename>...|:<classname | help | |
-disableassertions :<packagename>...|:<classname | disable assertions with specified granularity | help |
-agentlib libname>[=<options | load native agent library <libname>, e.g. -agentlib:jdwp see also -agentlib:jdwp=help | help |
-agentpath pathname>[=<options | load native agent library by full pathname | help |
-javaagent jarpath>[=<options | load Java programming language agent, see java.lang.instrument | help |
-splash imagepath | show splash screen with specified image HiDPI scaled images are automatically supported and used if available. | help |
-disable-@files | prevent further argument file expansion | help |
--enable-preview | allow classes to depend on preview features of this release | help |
--custom-providers provider>( | add configurations for custom providers | help |
-client | Selects the Java HotSpot Client VM. (in the manual page but not in --help) | man |
-Dproperty value | Sets a system property value. (in the manual page but not in --help) | man |
-d32 | Runs the application in a 32-bit environment. (in the manual page but not in --help) | man |
-d64 | Runs the application in a 64-bit environment. (in the manual page but not in --help) | man |
-jar filename | Executes a program encapsulated in a JAR file. (in the manual page but not in --help) | man |
-jre-restrict-search | Includes user-private JREs in the version search. (in the manual page but not in --help) | man |
-no-jre-restrict-search | Excludes user-private JREs from the version search. (in the manual page but not in --help) | man |
-server | Selects the Java HotSpot Server VM. (in the manual page but not in --help) | man |
-Xbatch | Disables background compilation. (in the manual page but not in --help) | man |
-Xcomp | Forces compilation of methods on first invocation. (in the manual page but not in --help) | man |
-Xdebug | Does nothing. (in the manual page but not in --help) | man |
-Xdiag | Shows additional diagnostic messages. (in the manual page but not in --help) | man |
-Xfuture | Enables strict class-file format checks that enforce close conformance to the class-file format specification. (in the manual page but not in --help) | man |
-Xint | Runs the application in interpreted-only mode. (in the manual page but not in --help) | man |
-Xinternalversion | Displays more detailed JVM version information than the -version option, and then exits. (in the manual page but not in --help) | man |
-Xmaxjitcodesize size | Specifies the maximum code cache size (in bytes) for JIT-compiled code. (in the manual page but not in --help) | man |
-Xmixed | Executes all bytecode by the interpreter except for hot methods, which are compiled to native code. (in the manual page but not in --help) | man |
-Xmnsize | Sets the initial and maximum size (in bytes) of the heap for the young generation (nursery). (in the manual page but not in --help) | man |
-Xmssize | Sets the initial size (in bytes) of the heap. (in the manual page but not in --help) | man |
-Xmxsize | Specifies the maximum size (in bytes) of the memory allocation pool in bytes. (in the manual page but not in --help) | man |
-Xnoclassgc | Disables garbage collection (GC) of classes. (in the manual page but not in --help) | man |
-Xrs | Reduces the use of operating system signals by the JVM. (in the manual page but not in --help) | man |
-Xsssize | Sets the thread stack size (in bytes). (in the manual page but not in --help) | man |
-Xusealtsigs | Use alternative signals instead of SIGUSR1 and SIGUSR2 for JVM internal signals. (in the manual page but not in --help) | man |
-Xincgc | Enables incremental garbage collection. (in the manual page but not in --help) | man |
-Xrunlibname | Loads the specified debugging/profiling library. (in the manual page but not in --help) | man |