How to run and JavaTM programs

Setting your JAVADIR and JOOSDIR environment variables

You must define the environment variables to point to the location of the directory containing JOOS and the directory containing an implementation of JDK1.1 (or later versions).

For students at McGill

To get the correct Java installation,
Add the following to your .cshrc file for the default installation for Java. Note that this is the method for setting environemnt variables for csh or tcsh . Users of bash should use the appropriate export commands for bash .
For the freeBSD machines, use something like the following (You can look in /usr/local to find the current Java installed):
setenv JAVADIR /usr/local/jdk1.4.1 
For the linux machines, use something like the following (You can look in /opt to find the current Java installed):
setenv JAVADIR /opt/sun-jdk-1.4.2.05 
Or on the Sun Solaris servers willy or mimi , use something like the following (check what is currently installed in /usr/local):
 
setenv JAVADIR /usr/local/j2sdk1.4.0_01  
 
Also, set the following for the C version of JOOS
 
setenv JOOSDIR /home/user/hendren/JOOS1.1
 

And set one of the following for the Java version, JJOOS.

    (for SableCC version 2)
setenv JJOOSDIR /home/user/hendren/SableCC/JJOOS
setenv SABLECCDIR /home/user/hendren/SableCC/sablecc-2.18.2   

-or-

    (for SableCC version 3) 
setenv JJOOSDIR /home/user/hendren/SableCC/JJOOS3
setenv SABLECCDIR /home/user/hendren/SableCC/sablecc-3-beta.3
 

You will be able to run the joos and java tools on willy or mimi (Sun Solaris) or any of the linux/freeBSD machines.

The Java version of the Joos compiler (commands jjoos and jjoosc must be run on a JDK 1.2 or later version.

Setting your PATH

Also, make sure that your path environment variable includes $JOOSDIR/Bin and $JAVADIR/bin:
set path = ($JOOSDIR/Bin $JAVADIR/bin $path)

Setting your CLASSPATH

Preset your CLASSPATH variable to include all the classes needed for JOOS, Java and Jasmin. Then you can use the ordinary java and jasmin commands. You must include at least the following:

setenv CLASSPATH .:$JOOSDIR/Lib:$JOOSDIR/Jasmin/jasmin/classes

Using the joos, jasmin, and dejava compiler tools


Compile JOOS programs (using the A+ compiler) into a similar collection of Jasmin files:
joos foo.java bar.java myexterns.joos $JOOSDIR/Extern/*.joos

or

jjoos foo.java bar.java myexterns.joos $JOOSDIR/Extern/*.joos
Note that ordinary class files should be given the extension .java so that they can also be compiled with Java compilers. By convention we use .joos extensions for all classes containing external JOOS class definitons. You may include your own (myexterns.joos) and/or all of the predefined ones ($JOOSDIR/Extern/*.joos).
Convert the Jasmin file foo.j into the class file foo.class:
jasmin foo.j
Note that jasmin is a script that executes the jasmin tool using the Java VM.
Compile JOOS/Java programs into a similar collection of class files using JDK:
javac foo.java bar.java
Note that all files must end with .java.
Execute and Verify the class file foo.class:
java -verify foo
Note that you must NOT give an extension.
Execute the class file foo.class:
java foo
Disassemble the class file foo.class into the Jasmin file foo.j:
D-Java -o jasmin foo > foo.j
which calls D-Java directly, or
dejava foo
which is a script that calls D-Java.
A script for the A+ compiler to automatically include the JOOS extern classes, and assemble the Jasmin files:
joosc foo.java bar.java

or

jjoosc foo.java bar.java