1. Home
  2. Computing & Technology
  3. Java

Creating Your First Java Program

By , About.com Guide

7 of 9

Compile Your Program

Compile Your Program

Microsoft product screen shot(s) reprinted with permission from Microsoft Corporation.

We’re now ready to compile the program. To do so, enter the command:

javac HelloWorld.java

After you hit Enter, the compiler will look at the code contained within the HelloWorld.java file, and attempt to compile it. If it can’t, it will display a series of errors to help you fix the code.

Hopefully, you should get the same result as me and have no errors. If that’s not the case, go back and check the code you’ve written. Make sure it matches the example code and re-save the file. Keep doing this until you can run javac without getting any errors.

Tip: Once your HelloWorld program has been successfully compiled, you will see a new file in the same directory. It will be called “HelloWorld.class”. This is the compiled version of your program.

Explore Java
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Java
  4. Getting Started
  5. Compile Your Program

©2009 About.com, a part of The New York Times Company.

All rights reserved.