This article is intended for beginners who are unfamiliar with setting up Java environments. As an example, let's look at how to run the Generation5 JDK demonstrations. Firstly, all the demonstrations require the individual Generation5 JDK CLASS files or JAR archive. The CLASS files can be downloaded by going to the Generation5 JDK SourceForge page and downloading the latest source zip file. The latest JAR file is always found at http://www.generation5.org/jdk/bin/generation5.jar. Note that this tutorial focuses on the Windows command-line, although the principles within Linux remain the same.
Setting up the Classpath
Whether you have downloaded the source or the JAR file, it must be placed in your classpath. The classpath tells Java where to look for library files. Let's say you have downloaded the Generation5 JDK source, and have unzipped it to a directory called "G5JDK". To add the source to your classpath, type the following at the command prompt:
set classpath=%classpath%;c:\g5jdk - or - set classpath=%classpath%;c:\g5jdk\generation5.jar
This appends the Generation5 JDK CLASS files or JAR to the current classpath (%classpath%). More permanent methods of setting the classpath are available but vary greatly according the OS you are using (even between Windows versions).
Running the Demonstrations
Demonstration programs are run using java, whereas applets are run using appletviewer. For example:
java -cp %classpath% CellDiagram - or - appletviewer -J-classpath -J%classpath% KohonenApplet.html
The first line will run the CellDiagram example, whereas the second line runs the Kohonen Applet. If you have problems getting these to run, check that a) java and appletviewer are in your PATH (appletviewer is often not included in the path by default) and b) classpath points to the Generation5 JDK CLASS files or JAR archive.
A few of the Generation5 JDK classes themselves have a main method that can be called, whether it is simply a test or has some form of functionality. To run these, you will have to call java something similar to:
java -cp %classpath% org.generation5.demos.Wolfram1DCA 3 126 480
To end this article, it is worth pointing out there are a few excellent open-source Java IDE programs to help develop your applications or applets with the JDK. Currently, I use NetBeans 3.6 which provides an excellent development environment with integrated form designers, Javadoc, debuggers, code folding and a lot more.
Remember that because Java is designed to work across many operating systems, different hardware and as standalone application or as an applet. As such, it can be very hard to setup especially from the commandline. If you have any problems, feel free to contact me or post to the Generation5 forums.
Article content copyright © James Matthews, 2004.
All content copyright © 1998-2007, Generation5 unless otherwise noted.