Table of Contents
This section is intended as a repository of acquired knowledge with respect to supporting technology used with DrJava. For each tool or library, a section will address questions like:
How is this technology used in the DrJava code base or build process?
How is the technology distributed; what needs to be done to install it?
Do we depend on a specific version of the software?
What are the key options or classes that developers should be aware of?
Where can more comprehensive documentation be found?
Why has this particular technology been chosen? What are the alternatives?
The Java language and APIs are documented by Sun at http://java.sun.com. The language actually exists in different "editions": Standard Edition (SE), Enterprise Edition (EE), and a collection of Micro Editions (ME). The Standard Edition is DrJava's target platform. See the JDK section of Getting Started for instruction on installing Java.
The language itself is documented by the Java Language Specification, available at http://java.sun.com/docs/books/jls. This is a good authoritative reference on the language, and any good Java developer should be familiar with it.
Java sources are compiled to a collection of class
files. These files can then be interpreted by a Java interpreter, which creates a Java virtual machine (JVM) and executes a class's main
method. Sun's java is one such interpreter.
Documentation on the java command can be found with Sun's Java tools documentation.
A typical invocation of the interpreter looks like this:
java -cp lib/plt.jar:classes/base edu.rice.cs.MyClass
The -cp
option specifies a class path — a collection of files or directories in which the necessary class
files are located. This path is searched from left to right; when the code makes reference to an unknown class name, the first matching class
file on the class path is used.
Directories of class
files may be packaged and compressed into a single jar
file for simplified distribution. These are essentially just zip
archives of class
file collections. In addition, a default main
class can be specified for a jar
file. Since all necessary classes for running DrJava are bundled into a single jar
file, this allows the application to be run with a simplified command syntax:
java -jar drjava.jar
Some other important options:
Assertions (Java assert
statements) in the code will be ignored when running unless they are explicitly turned on, using the -ea
option. The Ant script's run
and test
targets do this automatically.
Java properties can be defined using -D
options. (These are accessible within the program using key
=value
System.getProperty("
.)key
")
The JVM's heap size is fixed, and the default size is sometimes too small; to explicitly choose the maximum amount of memory the program can use, include the -Xmx
option.megabytes
M
DrJava is written in version 5 of Java, and makes extensive use of features that are new in that version. It's especially important that DrJava developers be quite comfortable with Java generics. Sun has posted a tutorial by Gilad Bracha that provides a good overview. There is also a a good summary of Java 5 features available in Sun's documentation.
The API specification is another essential reference for developers, available here: http://java.sun.com/j2se/1.5.0/docs/api/. A few important packages in the API include:
java.lang
The Object
class, wrapper classes, strings, Iterable
(the fundamental list interface), threads, and interface with the system are all defined here.
java.util
Standard lists, maps, and other collections are defined here. Note that the newer, non-synchronized classes (like ArrayList
) are usually preferred over their older, synchronized counterparts (like Vector
).
java.io
Provides access to file reading and writing and other file-system operations.
javax.swing
The DrJava GUI is implemented using Swing, the standard Java GUI framework. (Note that many Swing classes and concepts depend on the java.awt
package.)
java.rmi
Remote Method Invocation (RMI) provides a simple method-invocation model for inter-process communication. DrJava uses RMI to run the Interactions Pane interpreter in a separate process. Specific RMI documentation is available. Remote interfaces are interfaces that directly extend java.rmi.Remote
and whose methods are declared to throw a RemoteException
. Instances of these classes can be exported, which creates a server based on the object. Other processes can then create proxy objects implementing the remote interface type (the proxy's methods forward their calls to the server via TCP/IP networking; arguments and return values are serialized). In order for the client processes to locate the server, RMI applications typically register their exported objects with an RMI registry hosted at a well-known port; however, in DrJava (and many other applications) this is not necessary, and the server's information can simply be passed to the client process on startup.
The Java Tutorial provides a collection of small tutorials covering different parts of the APIs.
While new useful classes are included in each major release (such as version 6) of the Java platform, only those classes that will be available on all DrJava users' machines should be used in development. Thus, currently, only APIs available in Java 5 or previously should be used. (Newer classes and methods should be designated with a "since version
" tag in the API documentation.)