CodeWarrior At Stanford

CodeWarrior is a modern IDE (integrated development enviroment) that packages the compiler, editor, and debugger for Java, C, and C++. 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, and there is also a link including the many PDF docs for the compiler. The Mac clusters have the same Codewarrior image installed that you can download above.

Update there are some further updates (8.3) to the above download available from metrowerks that are worth installing for java development (although they are not crucial).

To run Java programs, you will also need to install a recemt Java JDK (Java Development Kit) from Sun. It's probably best to install the most recent JDK first, then Codewarrior. The "JRE" is different -- that's just for running Java, not compiling Java. PC and Linux people get Java from Sun. Mac OSX come with java installed by default. It's possible to run Java 1.1 on Mac OS 9, but that version of java is pretty old, so you we recommend OS X instead. The most recent Apple java updates are available from apple itself.

CodeWarrior Tips

Debugger Tips

Java on Mac OSX

Mac OSX includes a Java right out of the box. As of OSX 10.2, Java 1.3 is included. Older Mac OS versions can run Java 1.1, which can be made to work for most things, but using OSX is the easiest way to go. There are some OS9 instructions below, but we recommend OSX.

The Stanford Codewarrior image includes a simple Java 1.3 app project template to get started. All a project needs is the "rt.jar" file from the folder Codewarrior-Java Support- Libraries-JDK1.3. Codewarrior includes its own templates, but they include all sorts of extra junk that gets in the way, and I do not recommend them.

After compiling, the Run command runs the program. It will fork off a terminal window, and run the program from there. Or you can just use CodeWarrior to build, and then switch to the command line to run, just using the regular command line tools like 'java MyClass'. Or you can use CodeWarrior to build its output into a .jar file including a main-class manifest, and then just double click the .jar to run. The command line output goes to the console. Use the get-info panel of the .jar file to change it so it is opened by 'Jar Launcher'. The standard unix command line tools are there too, so you can switch to 'javac *.java' if you like. Trick: type 'cd' in a local terminal, then drag a folder icon to the terminal. It will paste in the path to that folder.

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. In some cases, an API will be Java 1.2 only, and so will not work on OS9, but you can work around those cases. (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 OS9

To move a Unix project to the Mac OS9: 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. Use the fixeol utility in the cs108/bin directory to fix the line endings of your text files for unix like this: '/usr/class/cs108/bin/fixeol *.java'. or just set CodeWarrior to use Unix line endings as its default.