Java Reference
In-Depth Information
java
Basic usage
java some.package.MyClass
java -jar my-packaged.jar
Description
java
is the executable that starts up a Java virtual machine. The initial entry point
into the program is the
main()
method that exists on the named class, and that has
the signature:
public
static
void
main
(
String
[]
args
);
This method is run on the single application thread that is created by the JVM
startup. The JVM process will exit once this method returns (and any additional
nondaemon application threads that were started have terminated).
If the form takes a JAR file rather than a class (the executable jar form), the JAR file
must contain a piece of metadata that tells the JVM which class to start from.
This bit of metadata is the
Main-Class
: attribute, and it is contained in the
MANI‐
FEST.MF
file in the
META-INF/
directory. See the description of the
jar
tool for
more details.
Common switches
-cp <classpath>
Define the classpath to read from.
-X, -?, -help
Provide help about the
java
executable and its switches.
-D<property=value>
Sets a Java system property that can be retrieved by the Java program. Any
number of such properties can be specified this way.
-jar
Run an executable JAR (see
the entry for jar
).
-Xbootclasspath(/a or /p)
Run with an alternative system classpath (very rarely used).
-client, -server
Select a HotSpot JIT compiler (see
“Notes” for this entry
).
-Xint, -Xcomp, -Xmixed
Control JIT compilation (very rarely used).
-Xms<size>
Set the minimum committed heap size for the JVM.