Java 6 in 21 Days (5th Edition): Using the JDK on Windows

The cover of Teach Yourself Java 6 in 21 Days (5th Edition) by Rogers Cadenhead

Home Buy the Book Thanks Other Books

Running Programs

The simplest way to run a program at the MS-DOS Prompt is to type its name and hit Enter. For example, type DIR and hit Enter to see a list of files and subfolders in the current folder.

You also can run a program by typing its name followed by a space and some options that control how the program runs. These options are called arguments.

To see an example of this, change to the root folder (using CD \) and type DIR J21work.You'll see a list of files and subfolders contained in the J21work folder.

After you have installed the Java Development Kit, you should run the Java interpreter to see that it works. Type the following command at an MS-DOS Prompt:

  • java -version

The -version argument tells the Java interpreter to display its version number. You can see an example of this below, but yours may be a little different depending on which JDK version you have installed.

Testing your JDK

If java -version works and you see a version number, it should begin with a "1.6" since you are using JDK 1.6. Sun sometimes tacks on a third number such as "1.6.1" to track maintenance and security releases, but as long as it begins with "1.6" you are using the correct version of the JDK Development Kit.

If you see an incorrect version number or a "Bad command or file name" error after running java -version, you need to make some changes to how the Java Development Kit is configured on your system.

To begin configuring the JDK, continue to the next page.