How to compile and run Java programs at CCS

On Solaris, at CCS:

It is important that you turn the Just-In-Time compiler feature off for the Java compiler you use. This feature is still buggy and causes weird run-time errors. I turn it off, by putting into my .software file:

JAVA_COMPILER=NONE

To compile:

jikes -classpath $CLASSPATH\:$JIKESPATH -d . -g +E *.java
(where JIKESPATH has the Java system classes, i.e. /usr/java1.2/jre/lib/rt.jar on Solaris). You have to introduce an environment variable JIKESPATH, for example in your .software file. I use:
JAVA_HOME=/usr/java1.2
PATH=$JAVA_HOME/bin
JAVA_COMPILER=NONE
# Location of JDK libs, for the Jikes compiler
JIKESPATH=$JAVA_HOME/jre/lib/rt.jar
in my .software file.

The +E gives error messages in a format that Emacs can parse. "jikes -help" shows all the available options.

jikes is at:

/arch/com/bin/jikes
An alternative to jikes is to use javac which is at /bin/javac. Why should you use jikes over javac? jikes gives you better error messages and it compiles much faster.

To run:

java Main
provided Main contains the main() method.

To get jikes for your machine, use: Jikes compiler home page.

Compiling Java files that have been created by Demeter/Java.

In some homeworks you get generated Java files to take the tedious work from you. The Java files live in a directory that has usually the name gen. Contents of generated java code.

To compile and run the provided Java classes, you need to put the file at http://www.ccs.neu.edu/research/demeter/DemeterJava/rt.jar into your CLASSPATH. This jar file contains only a few classes like Ident that are needed to run the provided program. They are all in the package EDU.neu.ccs.demeter.*.

The same file is also at: /proj/demsys/demjava/rt.jar for users of CCS Solaris machines. To compile them, use:

jikes -classpath $CLASSPATH\:$JIKESPATH -g *.java
If you prefer to use javac, you can simply use:
javac *.java
To run the program, use:
java Main < program.input
where program.input contains an object description that is given as input to your Java program. Study class Main.java to see how the parser is invoked.

Using jikes to compile Demeter/Java programs

You need to set your CLASSPATH encironment variable as described in the Demeter/Java setup file.

In one command, in csh or tcsh,

    env CLASSPATH=$CLASSPATH\:$JIKESPATH demjava MODULENAME
This is equivalent to, in sh, ksh, or bash,
    CLASSPATH=$CLASSPATH:$JIKESPATH demjava MODULENAME
where MODULENAME is one of the allowed modules, e.g. test, new, etc. Run demjava -help to see all possible module names. In the *.prj file it is recommended that you use
// Java compiler arguments.
COMPILE_ARGS =  -g -depend +E
for the compiler arguments.

From Doug Orleans: The crux of the matter is that jikes needs the Java library classes to be on the classpath, and the way it handles its own JIKESPATH variable is sort of strange (it doesn't add JIKESPATH to the CLASSPATH, it uses one or the other but not both). But I didn't feel comfortable just putting /usr/java1.2/jre/rt.jar in my CLASSPATH permanently, because Java doesn't need it. So I do it as I've described. Your mileage may vary.

Prepared by Karl Lieberherr with input from Doug Orleans and Johan Ovlinger.