Previous | Next | Trail Map | Writing Java Programs | The Nuts and Bolts of the Java Language


Running the Application

Before you can run the application, you must save it to a Java source file, and compile it. For more information about saving a Java source file, and compiling a java program, see the Saving, Compiling and Running an Application page in The Anatomy of a Java Application.

Now, you can run your application using the Java interpreter.

The output of the character-counting program depends on the input you enter for it. When a application reads from the standard input stream, like the character-counting application does, the application blocks waiting for you to type something in. The application continues to wait for input until you give it some indication that the input is complete. To indicate to any program that reads from the standard input stream that you have finished entering characters type the end-of-input character appropriate for your system at the beginning of a newline. When the character-counting program receives an end-of-input character it prints out the number of characters you typed.

In the UNIX example below, the user entered This is a test. and the application displayed Input has 16 chars.

% java Count
This is a test.
Input has 16 chars.
At first glance it may appear that the output is incorrect, since This is a test. has only 15 characters. But the user entered a newline as the 16th character.

If you have any problems, see Troubleshooting Interpreter Problems .

See Also

Compiler Man Page
Interpreter Man Page


Previous | Next | Trail Map | Writing Java Programs | The Nuts and Bolts of the Java Language