Make your own free website on
CMPnet AS/400e=Web Security.  Click here to find out why.

 Site Guide
 Latest Updates
 '96-'98 Articles Index

 Search NWC:
 best match

 Technology Guides
 Wide Area Systems
 Network Management
 Collaborative Computing
 OSes & Services
 Servers & Peripherals

 On Our Site
 Network Design Manual
 Interactive Buyer's Guide
 Interactive Report Card
 Online News
 Real-World Labs
 E-Mail Poll
 Frezza's Forum
 Workgroup Computing
 ITpro Downloads
 Well-Connected Awards

Sponsored by:
Click Here for 3COM

 CMPnet 3-D Site Map

 Site Services
 Advisory Forum
 Network Computing Links
 Best Jobs USA
and Marketing

Visionary Articles

 Web Connection
 Industry White Papers
 Special Supplements

CMPnet Resources
 Site Map
 Ad Info

 Free E-mail
 Sign Up Now 

Get PointCast - free!

Linux gobbles

"Tutorial" A Cup of Java -- With Two Lumps of Linux

By Jeffery Cann

Sun Microsystem's Java language has shaken the computer industry. Since March, 1997, over one million copies of the JDK 1.1 have been downloaded from JavaSoft's Web site. Java found a niche as a Web development tool, and now strives to be the development language of the 21st century. One great aspect of the Java language is that sophist icated development tools are available for anyone to download and use. Fortunately, for Linux users, the Java Development Kit (JDK), Version 1.1 is ready to roll.

Questions regarding this article should be directed to the author at

This is a tutorial article about locating, installing, and using the Java Development Kit (JDK) on Linux. It is intended for Linux developers; however, many aspects discussed are directly applicable to other Unix operating systems. You should have experience using development tools and some Linux system administra tion.

Java on Linux

Javasoft, the spin-off company of Sun Microsystems, Inc., has produced the JDK to run only on Solaris, Microsoft Windows (32-bit release), and Macintosh operating systems. Javasoft has left the porting work up to licensees who obtain the JDK specifications from Javasoft. The Blackdown Organization is responsible for the JDK port to Linux.

The Blackdown Organization started as an Internet service provider that currently houses the java-linux mailing lists and JDK/Linux archives. They provide the ``official'' port of Javasoft's JDK for Linux. The initial porting work was performed by Karl Asha, founder of the Blackdown organization. He continues to provide support and bug fixes for the JDK, in addition to maintenance of the Blackdown Web site. There have been many contributors to the JDK Linux port, most recently Randy Chapman and now Steve Byrne.

Information about the JDK for Lin ux may be found at Blackdown's Java Linux Page (<URL:>). You cannot download the JDK from this server, but you can obtain a list of Ftp mirror sites that contain the JDK. In addition, this site contains recent news on the Linux JDK, including latest release notes and bug fixes.

Java Development Kit

The JDK is a comprehensive suite of tools that one can use to produce Java applications or applets. The JDK includes the following:

  • Java run-time support
  • Java source files
  • Java tools
  • Demonstration applets
  • Installation notes for Solaris and Windows
  • Using Appletviewer
  • Using Java debugger

Java Tools is an impressive suite of development tools. The extensive HTML documentation is thorough, well-written, and useful. Overall, you have literally everything you need to produce sof tware written in Java.

Like all development tools, the JDK tools are designed to allow the developer to minimize time spent peforming routine tasks. Unlike many development tools, the JDK tools take this time-saving premise one step further. For example, the javadoc tool will generate HTML pages of documentation from notes in your Java source code. It will document the public and protected classes, interfaces, constructors, methods, and fields. In addition, you can denote documentation in your Java source by using the /** delimiter. Javadoc will look for this delimiter and include your comments. In a production environment, this tool alone could save many programmers hours of code research.

The javap tool will disassemble class files. Command-line options direct the verbosity of the output. For example, you can choose to output only the public members of the class. Included are command-line options for private, data-type signature, an d even the disassembled Java byte code for the class methods.

Another interesting tool is the javah , a C-header and stub-file generator. It will allow C code and Java code to interact directly by building C header files based on Java source. This can be used to implement native methods. The C structure definition in the header ( .h ) file contains the corresponding layout of the Java class. The structure fields correspond to the Java class instance variables.

The following table contains a complete description of each component of the JDK:

JDK Development Component Description
Java Run Time Core classes ( )
Java byte code interpreter
Java Source Files Code for public classes in .
Inc luded for instructional / demonstration purposes.
Java Tools Java Interpreter -- java
Java Compiler -- javac
Java Appletviewer -- appletviewer
Java Debugger -- jdb
Class File Disassembler -- javap
Java Documentation generator -- javadoc
C File Stub Generator -- javah
Java Archive Tool -- jar
Digital Signing Tool -- javakey
Native to ASCII -- native2ascii
Java RMI Stub Converter -- rmic
Java Remote Object Registry -- rmiregistry
Serial Version Command -- serialver
AWT 1.1 Conversion Tool -- updateAWT
Various C libraries
Demonstration Applets A full set of nifty applets that you can morph for your own Web applications.
Installation notes Ex tensive notes for Solaris and Microsoft Windows (32-bit). Linux JDK includes brief README to describe installation.
Using Appletviewer Appletviewer is used to view running Java applets. It removes the problems associated with developing applets using a proprietary Web browser.
Using Java Debugger Java debugger is a symbolic-line debugger, similar to GDB or DBX.

Installing the JDK

Although the JDK is contained in one archive file, there are two other files that you should consider downloading to round out the development system. Again, refer to the Blackdown Organization Java Linux Page to find the nearest Ftp site for downloading these archives.

[ Editor's note: Of course, newer releases become available as Java evolves. At the time this article is written, Linux 1.1.3 J DK is just becoming available, with 1.1.4 coming soon.]

jdk1_1_1_linux-v3_tar.gz , The JDK, version 1.1.1.
To install the JDK, I GNU unzipped and untarred this file into /usr/local . This will create a directory tree under /usr/local/jdk1.1.1 . You are not required to install into this path; however, if you do, you need not set the CLASSPATH environment variable (see `` Running Java Programs '' below).

Note: There is NO documentation in this archive! For documentation, you must download doc+demo archive (see next).

jdk1_1_1_doc+demo_tar.gz , The JAVA API documentation and the demonstration applets.
To install the documentation and demonstration programs, the archive was gunzipped and untarred in /usr/local . This will fill the directory structures /usr/local/jdk1.1.1/doc and /usr/loc al/jdk1.1.1/demo . Be sure to check out the new features of the jdk1.1.1 at /usr/local/jdk1.1.1/docs/relnotes/features.html .
Contents of the Documentation and Demonstration archive:
  • JDK Release Notes
  • JDK API Reference
  • JDK Guide To New Features
  • JDK Demos
  • JDK Tools Documentation
  • Java Tutorial

jre1_1_1_linux-v3_tar.gz , Java Run-time Environment
This is the minimum Java standard platform for running Java classes. Intended for vendors who want to bundle the JRE with their software, it will support run-time only systems.

There are future improvements slated for the JRE. Currently, bundling a Java software distribution is not automated. In addition, for each Java software distribution loaded on a workstation, you must have a corresponding JRE. Thus, if I have two Java applications from different vendors, I must have two JREs.
Con tents of the Java Run-Time Environment archive:
  • Java Virtual Machine (JVM)
  • Java Core Classes
  • Copyright and license information
  • JRE Binary Code License Agreement
  • How to bundle JRE
  • Required JRE bundle files
  • Optional JRE bundle files
  • Supporting files

Running Java Programs

One aspect of the JDK is its simple elegance. After the JDK archive is installed, you need only to set the CLASSPATH environmental variable and then you are ready to use the Java tools. One enhancement in the JDK release 1.1 over the JDK release 1.0 is that if you install the JDK into /usr/local/jdk.1.1.1 , then you do not even need to set the CLASSPATH variable.

The CLASSPATH environmental variable sets the path to the file. On other Unix operating systems, such as Solaris, this file is . If you installed t he jdk into /usr/local/jdk1.1.1 , then the file resides in the /usr/local/jdk1.1.1/lib .

In addition to the CLASSPATH variable, you may wish to place the path to the Java binaries: /usr/local/jdk1.1.1/bin in your PATH environmental variable.

Note: If you have previously installed the jdk1.0.2, you must unset your CLASSPATH variable.

Running a Java Applet

Applets are Java programs that follow a set of conventions so they can be run by a Web browser.

There are three steps to writing an applet:

  1. Write the Java class code.
  2. Successfully compile the Java code into byte code.
  3. Call the applet from an HTML page, using the <APPLET> tag.

Applets are distinguished from application programs in the class definition. All applets must be a subclass of the Applet class. This allows custom applets to inherit methods from the Applet superclass. In the ``Hello World!'' applet below, the import of the java.applet.Applet class file in line 1 will allow the applet code to inherit and reference the Applet class methods.

HelloWorld Applet

1    import java.applet.Applet;
2    import java.awt.Graphics;
4    public class HelloWorld extends Applet {
5        public void paint(Graphics g) {
6            g.drawString("Hello World!", 50, 25);
7        }
8    }

Writing and compiling Java code is discussed in the next section Running a Java Application . The demonstration applets provided with the JDK will be used to illustrate how to run an applet.

When attempting to run the demonstration HTML pages in a Netscape 3.0 browser, Netscape reported an error depicted in this image:

Netscape error window

The java_301 is a zipped file that contains Java classes. After installing it into the correct location, Netscape still showed the same error.

Netscape 3.0 only supports JDK 1.0.2. Thus, if you want to develop, test, and distribute Java applets that will run in Netscape 3.0, you should either compile your Java applets to be compatible with the JDK 1.0.2 (using the JDK 1.1.1) or retrieve the JDK 1.0.2. However, programmers should note the presence of the @deprecated comment in classes, fields, or methods. This is designed to signal which JDK 1.1.1 methods have superceded those in JDK 1.0. In the following code fragment the public method preferredSize is replaced by getPreferredSize .

 * @deprecated
 * @see #getPreferredSize
public Dimension preferredSize(){
	return getPreferredSize();

Note that the @deprecated flag is found in the comment section of a class. In addition, note the @see flag. This instructs the programmer to use the noted method as a replacement.

When the javac compiler finds the @deprecated flag in the comment section of a class, it will place a "Deprecated" flag in the output classfile. When a deprecated feature is used, the compiler will issue a warning.

Netscape's upgrade of Navigator has been rolled into the Communicator application suite. In a press release dated 10 Oct 1997, Communicator beta release 2 supports 95% of the JDK 1.1.1 features. When Communicator is in production, the JDK 1.1.1 is to be fully supported.

Javasoft provides the Appletviewer in lieu of a Web browser. The Appletviewer accepts an HTML page as input and will process the applet denoted by the <APPLET> HTML tag:

<TITLE>TicTacToe (1.0.2) App

<APPLET CODEBASE="1.0.2/" CODE="TicTacToe.class" WIDTH="120"
A 120x120 Tic Tac Toe applet is here.

<A HREF="1.0.2/">The source file</A>
<A HREF="1.1/example1.html">The 1.1 Version</A>


To use the Appletviewer to view (and play) a game of TicTacToe, you invoke the viewer in an xterm X Window System window.

Note: Be sure that the directory path to the Appletviewer executable is in your shell's PATH environment variable.

appletviewer /usr/local/jdk1.1.1/demo/TicTacToe/example1.html

Interestingly, the TicTacToe game has sound associated with the moves. Luckily, I had my speakers turned on! When I finally beat the applet, and won a game, it said ``Yahoo!''

Tac Toe game board

At the top of the applet, there is one pulldown menu labeled applet, which has several options:

Tic Tac Toe Applet pull-down menu

There are loads of interesting applets to demo. The source code for each class inside a demonstration applet is provided to peruse. These examples prove useful and interesting to see how Java is used.

Demonstration applets in the /usr/local/jdk1.1.1/demo directory includes:

Animator     ArcTest    BarChart    Blink          CardTest 
Clock        DitherTest DrawTest    Fractal        GraphLayout 
GraphicsTest ImageMap   JumpingBox  MoleculeViewer NervousText
SimpleGraph  SortDemo   SpreadSheet TicTacToe      WireFrame

The awt-1.1 examples are also Included in the /usr/local/jdk1.1.1/demos directory. AWT (Abstract Window Toolkit) is part of the Java API that provides methods common to GUI interfaces. For example, the java.awt.Button class creates a labeled button in your applet. T he AWT is documented in the /usr/local/jdk1.1.1/docs/api/packages.html file.

Running a Java Application

Java applications differ from Java applets in that they do not require a Web browser to execute. Also, they need not inherit the Applet class. Java applications are more flexible because they are stand alone. All you need to run a Java application are the application class files and the Java Run-time Environment (JRE).

If you have worked with C or C++ tools, compiling a Java application will be familiar. The code listing below is the application equivalent of the "Hello World!" applet. This program will print "Hello World!" to the standard output.

HelloWorld Application

1    /**
2     * The HelloWorldApp class is the Java implementation of the famous
3     * "Hello World" C language application.
4     * 
5     * HelloWorldApp will print "Hello World!" to the standard output.
6     */
8      class HelloWorldApp {
9          public static v
oid main(String args[]) {
10            //  display the string
11            System.out.println("Hello World!");
12         }
13    }

There are three steps to writing an application:

  1. Write the Java class source code.
  2. Successfully compile the Java code into byte code with javac .
  3. Run the application with java , the byte-code interpreter.

Use your favorite editor to enter the code for the HelloWorldApp class shown above. Save the file as . A public class, here HelloWorldApp, must be defined in a file named after that class, as in . The .java file-name extension is similar to a .c used in C or .cpp in C++.

To compile the file, execute the javac compiler at a shell prompt. (Be sure that the location of the jdk1.1.1/bin directory is in your shell's command search path.) The out put is an executable file, named HelloWorldApp.class .


To run the the HelloWorldApp, you invoke the java command at a command prompt, omitting the .class extension.

java HelloWorldApp


The documentation included with the demonstration applets is an excellent source of information. There are HTML manual pages to describe usage of the Java tools included in the JDK. If you installed the doc+demo archive into /usr/local/jdk1.1.1 , the JDK 1.1.1 documentation HTML index page will be located at: /usr/local/jdk/docs/index.html . This is a great resource page that has links to other local documentation. In addition, links to Javasoft and the Java tutorial are included.

Other Resources:

  • JavaSoft home page. This has the latest news and in formation about the JDK and Java.
  • Blackdown Organization is the source for Java on Linux.
  • On-line version of The Java Tutorial by Mary Campione and Kathy Walrath is an 830-page tutorial with 27 lessons that cover application and applet development. Lessons range from beginner to advanced levels.


In total, the JDK 1.1.1 is a solid development environment. The example code is well written, documented, and illustrative. The suite of development tools are extensive and sophisticated. To fully appreciate all the efforts of the Javasoft development team, you could spent many hours learning about Java.

Some developers who have used GUI Integrated Development Environments (IDEs), may find the character-based tools primitive. It is interesting that given that most GUI development environments are written as IDE interfac es, Javasoft does not showcase the JDK development environment.


Abstract Window Toolkit -- A set of Java classes that execute common GUI interface attributes, such as a scroll bar or window border.
Graphical User Interface -- An interface in which the program is rendered graphically, allowing the user to see its components while it executes. Typically, it implies support for a pointer device, such as a mouse.
Integrated Development Environment -- A development environment where all the development tools -- code editor, compiler, debugger, optimizer, etc. are contained within a single GUI environment.
Java Development Kit -- The suite of 14 development tools that is freely available to use to develop Java applications.
Java Run-Time Environment -- The minimum software necessary to run a Java application.

Author Biography

Jeffery Cann is an IVR (Interactive Voice Response) programmer in Denver, Colorado. He works on Unix in C and Oracle PL-SQL. Looking to bolster his knowledge of object-oriented languages, he has turned to Java to determine if it is applicable to asynchronous telephony applications.

Print This Page

e-mail Send as e-mail

NWC Home Site Guide WANsites UnixWorld Network Design Manual
Careers Network Computing Links ITpro Downloads Interactive Buyer's Guide
Online News Latest Updates Real World Labs Subscriptions WorkGroup Computing


CMPnet Click here for Sprint