C H A P T E R 1
Writing Your First Java Program
To write a program in Java, you need the Java Development Kit (JDK). Strictly speaking, the JDK is all you
need; however, other tools can make writing a Java application easier. Most software developers like to
use an Integrated Development Environment (IDE). One of the most popular IDEs is Eclipse.
Fortunately, both the JDK and Eclipse are free downloads. This chapter describes how to download and
install both products and how to set up your first Java project in Eclipse. By the end of this chapter, you
will have typed in and run your first Java program.
Installing the JDK
JDK is a collection of programs that enables you to write programs in Java. The two programs you'll use
most are javac.exe and java.exe. The javac.exe program is the compiler, which means it's the program
that turns code you can read (the code you write in Java) into code your computer can read (the
collection of 0s and 1s that a computer needs when it runs a program). The java.exe program runs the
programs that you write. After javac.exe compiles them, java.exe starts them and manages all the things
a program needs (a connection to the operating system, handles for files, and a lot of other things).
Because you'll use Eclipse (which we discuss shortly), you don't need to run javac.exe and java.exe.
Eclipse does that for you. But it's handy to know what they do, so that you can run programs directly
from a command window when you want to do so.
Before you can install it, you have to download it, of course. To get the latest version of the JDK,
follow these steps:
index.html in a web browser.
Click the Download JDK button.
Follow the instructions provided by the web site.
Run the installer and accept any defaults.