Using Java

You may use whatever version of Java you wish for 341. Alan recommends the current Sun implementation (JDK 1.2 beta 4). This is being installed on the lab machines, and should be available on the machines in Sieg 232. You can also get this free for a personal machine -- go to the java.sun.com web page and from there to the JDK 1.2 beta 4 link. (You have to register, but there is no charge.)

Microsoft J++ is installed in the PC Lab in Sieg 232, and is the official lab-supported version. (However, students in other classes have said that it was buggy.)

The version on orcas is really old (1.0.2), and won't work with all of the code in the book. (In particular it doesn't support inner classes.) However, a plus side is that you can use it easily from any remote terminal.

Using Java on NT

Java's JDK 1.2 beta is available in some NT labs (such as Seig 232). The executables should be in C:\apps\jdk1.2beta4\bin. On most machines the paths are already set up. Put your java source code in some directory. Get an MSDOS prompt and connect to that directory.

A sample program is HelloWorld.java or type:

public class HelloWorld
{
   public static void main(java.lang.String[] args)
   {
      java.lang.System.out.println("Hello World");
   }
}
To compile this program:
javac HelloWorld.java 
This should create a HelloWorld.class file containing the compiled Java bytecodes. You can now run these through the bytecode interpreter:
java HelloWorld
Hello World

Setup Problems

First make sure Java JDK 1.2 beta 4 is on your machine. Next check that C:\apps\jdk1.2beta4\bin is on your search path, and that the classpath environment variable is set to . (meaning current directory).

Adding C:\apps\jdk1.2beta4\bin to your PATH

To do this you should go to the Control Pannel and then click on the System icon. Select Environment from the list at the top. Then you are given a window viewing your environment variables. The variable PATH (case not important) should be there. You can click on it and then add C:\apps\jdk1.2beta4\bin. Note that NT seperates seperate items in the path with the ; character not the : character. Now you should hit the Set button and then the Apply button. You might have to logout and log back in again for the path change to really happen.

If you ave trouble getting this to work. You can go to a MSDOS prompt and type:

path C:\apps\jdk1.2beta4\bin;%path%

Using Java on orcas

To use Java on orcas you should first make sure that /usr/local/bin is in your path. You need access to javac, the Java compiler, and java, the Java bytecode interpreter. To make sure you have access to these programs, try the following:
orcas% which java
/usr/local/bin/java
orcas% which javac
/usr/local/bin/javac
Then to compile HelloWorld:
orcas% javac HelloWorld.java 
orcas% ls
HelloWorld.class  HelloWorld.java
Note that this created the HelloWorld.class file. This file contains the compiled Java bytecodes. You can now run these through the bytecode interpreter:
orcas% java HelloWorld
Hello World
You can follow this procedure to compile and run your own Java programs on orcas.