Compiling and running a Java Application

Usually it is easier to use Notepad or Wordpad in Windows. While the browser is displaying the source code, highlight the code and then click edit and copy (or hit Ctrl-c on the keyboard)
Switch to your editor and paste the code into your document.

If you insist you can still do it the hard way and type the lines in yourself.

Once you have entered the code.

  1. Save the source code under the name suggested in the lesson with the .java extension.

  2. Exit the text editor and return to a command prompt.

  3. Type "javac ******.java" at the command prompt.

    If there are any errors, return to the editor and ensure the source code is exactly the same as what you see in the lesson. Remember that Java is case sensitive. Check your upper case letters carefully.
    If there are no errors the compiler will work for a few seconds and then save a file called ******.class in the same directory.

  4. To run the .class file type "java ******" at the command prompt.
    (where ****** is the name of the .class file.)
    Do NOT type java ******.class. It will not execute if you do.

Hit the "Return to previous page" button on your browser

Back to the Table of Contents