How to compile and run Java programs at CCS

On Solaris, at CCS:

It is recommended that you use now the SUN javac compiler. It has been improved and should work well for your needs.

man javac
gives you documentation about the compiler.
which javac
tells you where it lives.

But jikes from IBM is also available.

To compile:

jikes -classpath $CLASSPATH\:$JIKESPATH -d . -g +E *.java
(where JIKESPATH has the Java system classes, currently /arch/unix/packages/j2sdk1_3_0beta/jre/lib/rt.jar on Solaris). You have to introduce an environment variable JIKESPATH, for example in your .software file. I use:
JAVA_HOME=/arch/unix/packages/j2sdk1_3_0beta
# Location of JDK libs, for the Jikes compiler
JIKESPATH=$JAVA_HOME/jre/lib/rt.jar
in my .software file. (The Java 2 SDK should already be in your path, if you have e.g. "@all" or "@gnu-all" in your .software file; use
which java
to find out where the current version is.)

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 from the Java 2 SDK. 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 DemeterJ.

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 the runtime support package (edu.neu.ccs.demeter.*), as well as DJ (edu.neu.ccs.demeter.dj.*) and the AP Library (edu.neu.ccs.demeter.aplib.*, edu.neu.ccs.demeter.aplib.cd.*, and edu.neu.ccs.demeter.aplib.sg.*).

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 DemeterJ programs

You need to add $JIKESPATH to your CLASSPATH environment variable when running demjava:

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 jre/lib/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 and Doug Orleans.