The Java Interpreter: java


[Page 821 (continued)]

The Java Interpreter: java

The java interpreter launches a Java application. This command takes one of the following forms:


java    [ options]   classname    [ argument ...]
java    [ options]   -jar               file.jar      [ argument ...]

If the first form is used, java starts a Java runtime environment. It then loads the specified classname and runs that class's main() method, which must be declared as follows:

public static void main(String args[]) 


The String parameter args[] is an array of strings used to pass any arguments listed on the command line. Command-line arguments are optional.

If the second form of the java command is used, java will load the classes and resources from the specified Java archive (JAR). In this case, the special -jar option flag must be specified. The options can also include many other command-line options, including the -classpath option.




Java, Java, Java(c) Object-Orienting Problem Solving
Java, Java, Java, Object-Oriented Problem Solving (3rd Edition)
ISBN: 0131474340
EAN: 2147483647
Year: 2005
Pages: 275

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net