Previous Section  < Day Day Up >  Next Section

An Overview of the JDK

Although 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:

  • It's free. You can download a copy at no cost from Sun's official Java World Wide Web site at http://java.sun.com.

  • It's first. Whenever Sun releases a new version of the language, the first tools that support the new version are in the JDK.

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.

By the Way

You might think there are more than three command-line arguments because of the spaces in the string Invasion of the Bee Girls. The quotation marks around that string cause it to be considered one command-line argument, which makes it possible to include spaces in an argument.


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


    Previous Section  < Day Day Up >  Next Section