The ACM Java Task Force (JTF) created an API framework for Java programs which is distributed in the file acm.jar.
Programs using acm.jar may be compiled and executed from the command line, or within your favorite Java IDE (e.g., Netbeans, DrJava). It is also possible to run your JTF programs as an applet within a browser or via the appletviewer.
While the IDEs have their own way of incorporating the acm.jar file, if you want it included at those times you are compiling or running java at the command line you have three options:
You can add ``-classpath .:/usr/share/java/acm.jar `` to your command as in:
javac -classpath .:/usr/share/java/acm.jar MyApplet.java
You can add acm.jar to your classpath in your current bash shell (your terminal session) with the following command:
test -z $CLASSPATH && export CLASSPATH=.:/usr/share/java/acm.jar || export CLASSPATH=.:/usr/share/java/acm.jar:$CLASSPATH
If you enter (or cut and paste) the above command in your terminal it will create a classpath for you if you don't have one, or it will add acm.jar to your existing classpath if you already have one.
If you are going to be using acm.jar regularly, the easiest thing to do in the long run is to set your classpath in your .bashrc file. 1) If you do this then once the change is in place any time you open a terminal your classpath will be set for you.
To make this modification, edit the file ~/.bashrc and add the following lines to it at the end:
# # Added to include current directory and acm.jar to the CLASSPATH # if [ -z "$CLASSPATH" ]; then export CLASSPATH=.:/usr/share/java/acm.jar else export CLASSPATH=$CLASSPATH.:/usr/share/java/acm.jar:$CLASSPATH fi
The lines above do the exact same thing as the ``test -z`` line in the previous section does, but they do it less opaquely and so are a better choice for your .bashrc file. Once you add these lines and save your .bashrc file, and time2) you open a terminal your classpath will be set for you.
The information that follows is largely obsolete, it is left here for reference purposes only
Here are Linux/Mac command line instructions for preparing your JTF programs to run as an applet:
``javac -classpath acm.jar MyApplet.java`` (this creates the file MyApplet.class)
``cp acm.jar MyApplet.jar``
``jar uf MyApplet.jar MyApplet.class``
<html> <applet archive=MyApplet.jar code=MyApplet.class width=500 height=300> </applet> </html>
``appletviewer MyApplet.html``