CodeWarrior At Stanford
CodeWarrior is a modern IDE (integrated development enviroment)
that packages the compiler, editor, and debugger.
Stanford has a site license for CodeWarrior Mac and PC.
The IDE and documentation may be downloaded
here with
a Stanford login. The download package includes the Java compiler
materials for each platform. (Codewarrior also does C and C++)
The Mac clusters have the same Codewarrior image installed that you
can download above. The Mac version includes a "Stanford Java App" stationery
that sets up a Java app on Mac OS 8/9 (Codewarrior also works on OSX).
To run Java programs, you will also need to install the Java VM.
It's probably best to install the JVM first, then Codewarrior.
PC and Linux people get Java from Sun.
Both Mac OS 8/9 and Mac OSX come with java installed by default.
Check for updates from from Apple
or use the Software Update control panel.
(Why don't windows machines come with Java installed by default? Must
be some sort of innocent mixup!)
CodeWarrior Tips
- Getting started: make a project, put your .java files in the same directory
add the .java files to the project. Set the main-class using the
"java target" preference.
-
Use command-0 to bring up the project window
- There is a button on the project window to bring up
the preferences for that project. Use the "java target" option
to specify the main class, and the "runtime settings"
to sepcify any command-line args.
- Look in the Java Support directory for a compressed archive of the java sources.
If you expand that archive, then Codewarrior will be able to pull up
Java source files very quickly, which can be a handy way to read the docs
(command-d with an empty selection).
-
(Mac) Pref "Java MacOS Settings" lets you specify that standard-in and standard-out
should be directed to a message window
-
The debugger is functional but slow.
-
The project must include the .jar files for the classes you are compiling
against (there is no CLASSPATH to fiddle with -- instead,
uses the .jar files are listed in the project).
-
Use command-k to just compile the file you are currently looking at --
fix the syntax error -- repeat. The CodeWarrior compiler is a lot faster
than javac. You can iterate through simple errors very quickly. This is
one area where the GUI/IDE really shines.
-
Use the "Find Definition command to skip to the definition of a method
-
Use command-e to enter the current selection as the find string, command-g
to cycle through the occurences of that string
-
Use command-shift-b to got "back" if you've been following symbols forward
Debugger Tips
-
The debugger is slow at stepping -- set breakpoints and "run" to keep it
bareably fast
-
Click the little button in the stack variable display to set it to "auto"
instead of "all".
-
Use the "breakpoints" window to turn breakpoints on and off temporarily,
without removing them from the source -- handy!
Java on MacOS
MacOS 8/9 supports only Java 1.1, however Swing and Collections can be
retrofited to it so it works fine for most purposes. (The files
mentioned here are included with the Codewarrior download above.)
Put the swingall.jar and collections.jar files in Codewarrior:Java Support:Libraries
folder -- this makes the classes available at compile time. Also place copies
of those jar files and MWDebugger.jar in the MRJClasss
folder in the extensions folder of the system folder. This makes the classes
available at run time.
Unix <-> Mac
To move a Unix project to the mac: bring over the .java files, make the
stationery project, add the .java files. Include the "import com.sun.java.util.collections.*;"
line in source files using collections.
To move Mac to Unix: move the .java files back to Unix. Comment out
the "import com.sun.java.util.collections.*" line. There probably needs
to be an import java.util.*; line, and it can be left in for the Mac builds.