You may use whatever implementation of Java you wish for 341, subject to the caveat that only Java 1.2-compliant implementations will run all the code in the textbook (though 1.1 compliant implementations will run 99%). Alan recommends the current Sun implementation (JDK 1.2). This is 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 look under "Products and APIs" to get the JDK 1.2, a.k.a. the "Java 2 Platform". The Java 2 Platform comes in several varieties; we recommend SDK Standard Edition version 1.2.2
Microsoft J++ is installed in the PC Lab in Sieg 232, and is the official lab-supported version. However, it may not be entirely compliant with the Java specification.
The Linux port of Sun's JDK 1.2 is available on the instructional linux machines (tahiti etc.).
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.javaThis should create a HelloWorld.class file containing the compiled Java bytecodes. You can now run these through the bytecode interpreter:
java HelloWorld Hello World
If you have trouble getting this to work, you can go to a MSDOS prompt and type:
path C:\jdk1.2\bin;%path%
tahiti% which java /usr/local/bin/java tahiti% which javac /usr/local/bin/javacThen to compile HelloWorld:
tahiti% javac HelloWorld.java tahiti% ls HelloWorld.class HelloWorld.javaNote that this created the HelloWorld.class file. This file contains the compiled Java bytecodes. You can now run these through the bytecode interpreter:
tahiti% java HelloWorld Hello WorldYou can follow this procedure to compile and run your own Java programs.