1. Technology

Creating Your First Java Program


5 of 9

The Java Compiler
Set the Compiler Path

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

Another example of a console program is the Java compiler called "javac". This is the program that will read the code in the HelloWorld.java file, and translate it into a language your computer can understand. This process is called compiling. Every Java program you write will have to be compiled before it can be run.

To run javac from the terminal window, you first need to tell your computer where it is. On my machine it’s in a directory called "C:\Program Files\Java\jdk\1.6.0_06\bin". If you don’t have this directory, then do a file search in Windows Explorer for "javac" to find out where it lives.

Once you’ve found its location, type the following command into the terminal window:

 set path= *the directory where javac lives*


 set path=C:\Program Files\Java\jdk\1.6.0_06\bin 

Press Enter. The terminal window won’t do anything flashy, in fact it will just return to the command prompt. However, the path to the compiler has now been set.

  1. About.com
  2. Technology
  3. Java
  4. Getting Started
  5. Creating Your First Java Program: The Java Compiler

©2014 About.com. All rights reserved.