How to prepare your system for using
Java
Before you can develop Java applications, the JDK must be installed on
your system. In addition, your system may need to be configured to work with
the JDK. Once you install the JDK, you'll be ready to create your first Java
application.
How to install the JDK
Figure 1-4 shows how to install the JDK. To start, you download the exe file
for the setup program for the most recent version of the JDK from the Java web
site. Then, you navigate to the directory that holds the exe file, run the setup
file, and respond to the resulting dialog boxes.
Since Sun periodically updates the Java web site, we've kept the procedure
shown in this figure somewhat general. As a result, you may have to do some
searching to find the current version of the JDK. In general, you can start by
looking at the downloads for Java SE. Then, you can find the most current
version of the JDK for your operating system.
By the way, all of the examples in this book have been tested against
version 6 of the JDK. Since Java has a good track record of being upwards
compatible, however, these examples should work equally well with later
versions of the JDK.
The Java web site
java.sun.com
How to download the JDK from the Java web site
1. Go to the Java web site.
2. Locate the download page for Java SE 6.
3. Click on the Download button for JDK 6 and follow the instructions.
4. Save the exe file for the setup program to your hard disk.
How to install the JDK
- Run the exe file and respond to the resulting dialog boxes. When you're prompted for the
JDK directory, use the default directory. For most Windows systems, the default directory is C:\Program Files\Java\jdk1.6.0 for Java SE 6.
Notes
- For more information about installing the JDK, you can refer to the Java web site.
- If you are installing the Windows version of the JDK, you can perform either an offline
or an online installation. An online installation is faster because only a small setup file is
downloaded. However, you must remain online during the entire installation so the
required files can be installed.
A summary of the directories and files of the JDK
Figure 1-5 shows the directories and files that are created when you install
the JDK. Here, the JDK is stored in the C:\Program Files\Java\jdk1.6.0 directory. This directory has multiple subdirectories, but the bin, jre, lib, and docs
directories are the most important.
The bin directory holds all the tools necessary for developing and testing a
program, including the Java compiler. Later in this chapter, you'll learn how to
use these tools to compile and run Java applications. The lib directory contains
libraries and support files required by the development tools.
The jre directory contains the Java interpreter, or Java Runtime Environment
(JRE), that's needed to run Java applications once they've been compiled.
Although the JDK uses this internal version of the JRE, you can also download
a standalone version of the JRE from the Java web site. Once you're done
developing a Java application, for example, you can distribute the standalone
JRE to other computers so they can run your application.
The docs directory can be used to store the Java documentation. Later in
this chapter, you'll learn how to download and install this documentation.
In the JDK directory, you can find an HTML readme file that contains much
of the information that's presented in this figure as well as more technical and
detailed information about the JDK. You can view the HTML file with a web
browser.
The JDK directory also contains the src.zip file. This is a compressed file
that holds the source code for the JDK. If you want to view the source code, you
can extract the source files from this zip file. If you're curious to see the Java
code of the JDK, you may want to do that once you understand Java better.
When you work with Windows, you'll find that it sometimes uses the termsfolder and subfolder to refer to directories and subdirectories. For consistency,
though, we use the term directory throughout this book. In practice, these terms
are often used interchangeably.
The default directory for the JDK on a Windows machine
C:\Program Files\Java\jdk1.6.0\bin
Four important subdirectories of the JDK
Directory |
Description |
| bin |
The Java development tools and commands. |
| jre |
The root directory of the Java Runtime Environment (JRE). |
| lib |
Additional libraries of code that are required by the development tools. |
| docs (optional) |
The on-line documentation that you can download (see figure 1-15). |
Two important files stored in the JDK directory
File |
Description |
| readme.htm |
An HTML page that provides information on Java SE, including system requirements, features,
and documentation links. |
| src.zip |
A zip file containing the source code for the Java SE API. If you use a zip tool such as WinZip
to extract these directories and files, you can view the source code for the JDK. |
Description
- The Java Runtime Environment (JRE) is the Java interpreter that allows you to run
compiled programs in Java. The jre directory is an internal copy of the runtime environ-
ment that works with the JDK. You can also download a standalone version of the JRE
for computers that don't have the JDK installed on them.
Figure 1-5
Introduction to Java ...................................................................... 4
Toolkits and platforms ....................................................................... 4
Java compared to C++ ...................................................................... 4
Java compared to C# ........................................................................ 4
Applications, applets, and servlets ....................................................... 6
How Java compiles and interprets code ................................................ 8
How to prepare your system for using Java .................................. 10
How to install the JDK ..........................................................................10
A summary of the directories and files of the JDK ...................................12
How to set the command path ...............................................................14
How to set the class path ..................................................................... 16
How to use TextPad to work with Java ........................................... 18
How to install TextPad ......................................................................... 18
How to use TextPad to save and edit source code ................................... 20
How to use TextPad to compile source code ........................................... 22
How to use TextPad to run an application ............................................... 22
Common error messages and solutions ................................................. 24
How to use the command prompt to work with Java ...................... 26
How to compile source code ................................................................. 26
How to run an application ..................................................................... 26
How to compile source code with a switch .............................................. 28
Essential DOS skills for working with Java ............................................. 30
How to use the documentation for the Java SE API ....................... 32
How to install the API documentation ..................................................... 32
How to navigate the API documentation ................................................. 34
Introduction to Java IDEs ................................................................ 36
The Eclipse IDE for Java ....................................................................... 36
The NetBeans IDE ................................................................................ 38
The BlueJ IDE ...................................................................................... 38
Perspective ....................................................................................... 40
| The chapter 1 of Murach's Java SE 6 excellent book (it is a MUST for all newbees!) is published on our site with written permission of the copyright owner. It was slightly adapted to our site layout. If you want to take a look at PDF version please follow the link here. |
12253 bytes more | comments? | | Score: 0
|