Java JDK Basic Tool介绍

来源:互联网 发布:淘宝客服月薪大概多少 编辑:程序博客网 时间:2024/05/17 21:29
(2006-04-21 15:31:59)
 
JavaC DESCRIPTION
The javac tool reads class and interface definitions, written in the Java programming language, and compiles them into bytecode class files.

There are two ways to pass source code file names to javac:

  • For a small number of source files, simply list the file names on the command line.
  • For a large number of source files, list the file names in a file, separated by blanks or line breaks. Then use the list file name on thejavac command line, preceded by an @ character.
Source code file names must have .java suffixes, class file names must have.class suffixes, and both source and class files must have root names that identify the class. For example, a class calledMyClass would be written in a source file called MyClass.java and compiled into a bytecode class file calledMyClass.class.

Inner class definitions produce additional class files. These class files have names combining the inner and outer class names, such asMyClass$MyInnerClass.class.

You should arrange source files in a directory tree that reflects their package tree. For example, if you keep all your source files in\workspace, the source code for com.mysoft.mypack.MyClass should be in\workspace\com\mysoft\mypack\MyClass.java.

By default, the compiler puts each class file in the same directory as its source file. You can specify a separate destination directory with-d (see

Options,below).

Java DESCRIPTION

The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class'smain method.

The method must be declared public and static, it must not return any value, and it must accept aString array as a para meter. The method declaration must look like the following:

 public static void main(String args[])
By default, the first non-option argument is the name of the class to be invoked. A fully-qualified class name should be used. If the-jar option is specified, the first non-option argume nt is the name of aJAR archive containing class and resource f iles for the application, with the startup class indicated by theMain-Class manifest header.

The Java runtime searches for the startup class, and other classes used, in three sets of locations: the bootstrap class path, the installed extensions, and the user class path.

Non-option arguments after the class name or JAR file name are passed to the main function.

The javaw command is identical to java, except that withjavaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. Thejavaw launcher will, however, display a dialog box with error information if a launch fails for some reason.

原创粉丝点击