To run a Java
Application using the Java Virtual Machine (JVM), you type something
like the following, to invoke the bare SDK JVM (Java Virtual Machine, a.k.a. The
Java Application Launcher):
java HelloWorld
(the .class is not allowed
-- HelloWorld refers to the classname;
the JVM tries to find the specified class in the classpath.)
This runs the HelloWorld class.
The syntax for invoking the java application launcher (JVM) is:
java [ options ] class [ argument ... ]
java [ options ] -jar jarfile [ argument ... ]
javaw [ options ] class [ argument ... ]
javaw [ options ] -jar jarfile [ argument ... ]
where:
| Command line parameter |
Meaning |
options
|
Command-line options. |
class
|
Name of the class to be invoked. |
jarfile
|
Name of the jar file to be invoked. Used only with the -jar
option. |
argument
|
Argument passed to the main function. |
Options include (this is a subset of the full set of options; see
the Java 2
SDK Tools and Utilities documentation for details):
| Option |
Explanation |
-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 (;). 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 (.). |
-Dproperty=value
|
Sets a system property value. (Multiple such options may be
specified.) |
-verbose
|
Display information about each class loaded. |
-version
|
Display version information and exit. |
-?
-help |
Display usage information and exit. |
|