< Day Day Up > |
An Overview of the JDKAlthough there are several dozen development environments you can use to create Java programs, the most widely used is the Java Development Kit (JDK) from Sun Microsystems, the set of command-line tools that are used to develop software with the Java language. There are two main reasons for the popularity of the kit:
The JDK uses the command line—also called the MS-DOS prompt, command prompt, or console under Windows; and the shell prompt under Unix. Commands are entered using the keyboard, as in the following example: javac VideoBook.java This command compiles a Java program called VideoBook.java using the JDK compiler. There are two elements to the command: the name of the JDK compiler, javac, followed by the name of the program to compile, VideoBook.java. A space character separates the two elements. Each JDK command follows the same format: the name of the tool to use followed by one or more elements indicating what the tool should do. These elements are called arguments. The following illustrates the use of command-line arguments: java VideoBook add VHS "Invasion of the Bee Girls" This command tells the Java interpreter to run a class file called VideoBook with three command-line arguments: the strings add, VHS, and Invasion of the Bee Girls.
Some arguments used with the JDK modify how a tool functions. These arguments are preceded by a hyphen character and are called options. The following command shows the use of an option: java -version This command tells the Java interpreter to display its version number rather than trying to run a class file. It's a good way to find out whether the JDK is correctly configured to run Java programs on your system. Here's an example of the output run on a system equipped with JDK 5.0: java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build1.5.0) Java HotSpot(TM) Client VM (build 1.5.0, mixed mode) The version reflects Sun's internal number for the JDK 5, which is 1.5. In some instances, you can combine options with other arguments. For example, if you compile a Java class that uses deprecated methods, you can see more information on these methods by compiling the class with a -deprecation option, as in the following: javac -deprecation OldVideoBook.java |
< Day Day Up > |