Java Reference
In-Depth Information
Installing and configuring a JDK
Before you can write your first line of Java code in
IDEA
, you must install and con-
figure at least one
JDK
.
IDEA
ships with its own Java runtime environment (
JRE
),
but it doesn't come with a Java compiler or an
API
library—and with good reason.
Unlike some development environments that integrate a particular version of
the
JDK
,
IDEA
handles the inclusion of the project's underlying
JDK
in a modular
fashion. It gives you the ability to develop with any
JDK
, including versions that
haven't been released yet. This means you can use
IDEA
to develop applications
for Java 1.2, Java 1.4, Java 1.5, and so on—at whatever patch level you require.
Perhaps just as important,
IDEA
gives you the ability to use
JDK
s distributed by
vendors other than Sun Microsystems. Obviously, any new features that are added
to future versions of the Java language may require an update of
IDEA
in order to
be fully supported.
If your system doesn't have a
JDK
installed, you need to download a copy
from the Sun Microsystems web site (http://java.sun.com). Download the appro-
priate language and version for your system, but be sure to get the
JDK
, not the
JRE
(which only allows you to run Java applications, not develop them). When
you're installing the
JDK
, be sure to install the source files (if they're included
with your distribution).
IDEA
uses them to provide improved coding and quick-
doc assistance.
We also strongly recommend that you download the documentation for your
JDK
. It's usually distributed as a separate package, due to its size, but you'll find it
an invaluable resource. As you'll learn,
IDEA
can use the documentation to pro-
vide contextual help while you're developing. You can install these files anywhere,
but it makes sense to install them into the
JDK
's root directory.
If you clicked
Configure
in step 3 in the previous section, you should see the
JDK
& Global Libraries
window shown in figure 1.6. To configure your first
JDK
,
follow these steps:
Click the plus button (
+
) at the top of the window to add a new
JDK
.
This button works very much like the ellipsis button, but it's reserved for
adding new entries to a list as opposed to populating a test field with a
single answer.
4
The
Select Path
dialog appears and prompts you to choose a directory
from the file system. Use the tree control to navigate to the home direc-
tory of your
JDK
installation (for example, C:\j2sdk1.4.2_08 for the latest
release of the 1.4.2
JDK
on Windows).
5