Software Guide

This Web page describes the software that we have provided for you on the course CD.

The Java Development Kit

The components

This is the collection of tools that you will use to compile, run and debug Java programs. The components of the kit are:

  • appletviewer
  • java
  • javac
  • javadoc
  • javah
  • javap
  • jdb

The appletviewer is a utility which is used to display code which has been embedded into HTML files. It is used to debug a small Java program called applets. Normally you will use a browser for this, although some of the exercises ask you to use the appletviewer.

java is the interpreter that runs the object code produced by the Java compiler javac. You will use this program very frequently.

javac is the compiler for the Java programming language. This processes a character file containing Java source code and produces a class file which can be executed by java. Again, you will use this program very frequently.

javadoc is the Java documentation generator. This tool takes Java source code into which has been embedded special comments and will produce HTML files that contain useful documentation about the code that has been processed. You will not be using this utility.

javah is the native method C file generator. This is used to interface code written in C with the Java code that you have written. You will not be using this program on the course.

javap is a class disassembler. It processes the object code produced by java and displays it in a human readable form. You will not be using this program during the course.

jdb is a very primitive debugger which allows you to carry out common debugging functions such as examining variable values. We hope that you will not use this program on the course, but rely on inserting your own print statements in the code whenever you have run-time problems.

There is an extensive collection of documentation on the Java libraries on your course CD, which can be examined by using your browser. There is also an introduction on how to access these libraries.

Using the JDK

The aim of this section is to briefly describe how you would use the compiler and interpreter for Java.

You will need to open an MSDOS command window in order to run both the compiler and the interpreter. You will also need an editor which is capable of producing character files, such as the PFE32 editor we have provided. The normal process of compiling and running a Java program is:

  1. Create the program using your chosen editor.
  2. Store the program in the file ClassName.java within the folder M874Programs, where ClassName is the name of the class which is in the file. It is important that you use this directory for all the programs which you develop on the course. If there is more than one class in the file then nominate only one of the classes as public by prefacing it with the keyword public and use that class name.
  3. Type javac Classname.java. Your program will now compile and will either produce syntax errors or will compile cleanly.
  4. If syntax errors were produced then correct them and recompile the code.
  5. Once the code has been clean compiled then type java Classname and the object code will be executed and your results will be displayed.

This is a brief description of the process of compiling and running a Java application. One of the first exercises in the course will take you through this process in a step-by-step fashion. A later set of exercises will give you instructions on how to develop applets: code which can be embedded in a Web document. In essence there are a number of steps to carry out:

  1. Use your chosen editor to store the code for the applet in a file. Store the code in the file ClassName.java, where ClassName is the name of the applet class. This file must be stored in the folder M874Programs.
  2. Open an MSDOS prompt window and compile the code by typing the line javac Classname.java.
  3. Correct any syntax errors and recompile the code.
  4. Develop a file containing HTML statements which include a reference to the applet code using your chosen editor. This must be placed in the folder M874Programs. Every exercise that requires the development of an applet will provide you with this code.
  5. Use your browser or the appletviewer to execute the applet and check on its correctness.

The Pfe 32 editor

This is an editor which can be used to produce source code files for both the JDK and your browser. It has a full set of on-line help facilities. It can be found in the directory M874Software.