Workshop: Running a Java Program

To run the Java program you have just created, you must use a Java interpreter such as java, the command-line tool included with the Java Development Kit. An interpreter makes the computer follow the instructions you gave it when you wrote the program.

To run a Java program, the command java is followed by a space and the name of the class file that contains the program. Although the class file's name includes the .class extension, this part of the name must be left off when running the program with the Java interpreter.

To see whether the Saluton program does what you want, run the class. If you're using the kit, go to the folder that contains the Saluton.class file and type the following at a command line:

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.