![]() |
School of Engineering and Applied
Science
Department of Computer Science CSci 190 -- Real Time Computer Systems http://www.seas.gwu.edu/~csci190 Prof. Michael B. Feldman mfeldman@gwu.edu |
Using GNAT requires setting up a few path variables and aliases. This
is all handled by a shell script, which you invoke by typing
. ~csjava/setup-java
Note the dot and the tilde. If you add this line to the .profile
file in your home directory, it's executed automatically every time you
log in.
You must also add the following line to the .kshrc file in your home directory:
export CLASSPATH=..:.:/usr/java/jre/lib/rt.jar:/home/projects/csjava/classes
Java compilers and virtual machines are very fussy about the directory locations of source (.java) and output (.class) files, so make sure to copy the above line exactly.
The setup gives you a locally-written simple script, jcompile, that allows you to compile one or more source files at a time. The advantages of this script are:
Try moving in your directory to javasource/csci190, list the directory so you know what's there, and use the Sun compiler to compile something:
javac -verbose ShowThreads.java
List the directory again, and you'll see the .class files that were generated. Now run the program:
java -verbose ShowThreads
Notice how many system classes a simple program uses!
Now you can compile a single program with jcompile:
jcompile ShowThreads.java
and notice that you now have ShowThreads.lis, your listing file. Examine it with an editor, or cat. You can get .class files and listings for everything by typing
jcompile *.java
Both compilers produce compatible output for the JVM, so you can freely intermix javac and Jikes compilations. In either case, you run a program by typing java.
You might try deliberately putting a syntax or semantic error in one of the files and observe the diagnostic information from the two compilers.
A great Windows, Linux, and Mac (OS X) editor is jGRASP, which you can
download from its home site at
http://www.eng.auburn.edu/grasp/
This editor is "smart" and "understands" the syntax of many languages, including both Ada 95 and Java.