The Java Programming Environment

Installation and Development:

• Installing the Java Software Development Kit
• Development Environments

Now you will learn how to install the Java Software Development Kit (SDK) and how to compile and run various types of programs: console programs, graphical applications, and applets. You run the SDK tools by typing commands in a shell window. However, many programmers prefer the comfort of an integrated development environment. We show you how to use the freely available Forte environment to compile and run Java programs. There are many other environments for developing Java applications with similar user interfaces.

While easier to learn and use, integrated development environments take a long time to load and require heavy resources. As a middle ground, you may want to use a text editor that can call the Java compiler and interpreter. We show you a couple of text editors with Java integration.


Installing the Java Software Development Kit:

The most complete versions of Java are available for Sun's Solaris 2.x, Windows NT/2000, or Windows 95/98. Versions of Java in various states of development exist forLinux, OS/2, Macintosh, Windows 3.1, and many other platforms. Installation directions differ on each platform.Only the installation and compilation instructions for Java are system dependent. System independence is a major benefit of Java.

On Windows, simply run the self-installing executable file. On Solaris, look inside the compressed tar file for a README file. For other platforms, you'll need to consult the platform-specific installation instructions.

The setup procedure offers a default for the installation directory that contains the Java SDK version number, such as jdk1.2.3. If you prefer,you can change the installation directory to jdk. However, if you are a Java enthusiast who enjoys collecting different versions of the Java SDK, go ahead and accept the default.

For example, when we refer to the jdk/bin directory, we mean the directory named bin under the Java SDK installation directory. Under Windows, you'll have to use backslashes and drive letters such as c:\jdk\bin.

Setting the Execution Path:

After you are done installing the Java SDK, you need to carry out one additional step: add the jdk/bin directory to the execution path, the list of directories that the operating system traverses to locate executable files. Directions for this step also vary among operating systems.


Under Windows NT/2000, start the control panel, select System, then Environment.Scroll through the User Variables window until you find a variable named PATH. Add the jdk\bin directory to the beginning of the path, using a semicolon to separate the new entry, like this:
c:\jdk\bin;other stuff

Save your settings. Any new console windows that you start have the correct path.Here is how you test whether you did it right:Start a shell window. How you do this depends on your operating system. Type the line java -version and press the enter key. You should get a display such as this one: java version "1.3.0"

Java(TM) 2 Runtime Environment, Standard Edition
Java HotSpot(TM) Client VM

If instead you get a message such as “java: command not found,” “Bad command or filename,” or “The name specified is not recognized as an internal or external command, operable program or batch file,” then you need to go back and double-check your installation.


Installing the Library Source and Documentation in Java:

The library source files are delivered in the Java SDK as a compressed file src.jar , and you must unpack that file to get access to the source code. We highly recommend that you do that.

Simply do the following:

1. Make sure the Java SDK is installed and the jdk/bin directory is on the execution path.

2. Open a command shell.
3. Change to the jdk directory (e.g. /usr/local/jdk or C:\jdk).
4. Execute the command: jar xvf src.jar

The src.jar file contains the source code for all public libraries.

If you decide to use jar, follow these steps:


1. Make sure the Java SDK is installed and the jdk/bin directory is on the execution path.

2. Copy the documentation zip file into the directory that contains the jdk directory(such as /usr/local or C:\). The file is called jdkversion-doc.zip, whereversion is something like 1_2_3.
3. Open a command shell.
4. Change to the directory that contains the jdk directory and the compressed documentation file.
5. Execute the command: jar xvf jdkversion-doc.zip
where version is the appropriate version number.

RELATED POST

JAVA OPERATORS

No comments:

Post a Comment