1. Home
  2. Computing & Technology
  3. Java

Building Your First Java Applet

By Paul Leahy, About.com

5 of 10

The Java Compiler

Compile the Applet

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

We need the terminal window to access the Java compiler called “javac”. This is the program that will read the code in the FirstApplet.java file, and translate it into a language that your computer can understand. This process is called compiling. Just like Java applications, Java applets must be compiled too.

To run javac from the terminal window, you need to tell your computer where it is. On my machine, it’s in a directory called “C:\Program Files\Java\jdk1.6.0_06\bin”. If you don’t have this directory, then do a file search in Windows Explorer for “javac” and 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*

E.g.,

set path=C:\Program Files\Java\jdk1.6.0_06\bin

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

Explore Java
About.com Special Features

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

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Java
  4. Tutorials
  5. The Java Compiler

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

All rights reserved.