Sams Teach Yourself Java 6 in 21 Days

Using the JDK on a Windows System

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.


Search terms used to find this page: Java programming, teach yourself, 21 days, how to, learn, Sams, Pearson, Macmillan, Java 6, JDK 6, Java6, JDK1.6, Java 1.6, JDK 1.6, SDK1.6, Java 6 SDK 1.6, SDK 1.6, Java 6 version 1.6, Java 6 SDK, Java SDK, Rogers Cadenhead, Laura Lemay, tutorial, hands-on, source code, code, javac, java, application, appletviewer, help, learning, applet, servlet, servlets, JSP, Swing, GUI, interface, XML, JavaSound, Java2D, JDBC, JavaBeans, object serialization, IO, Tomcat, Apache, Java API for XML Parsing, Java API for XML Processing, XML-RPC, XOM, Web services, regular expressions, regex, java.nio, buffers, channels

Valid HTML 4.01!

Valid CSS!