INFS 590: OSF1 Java Instructions

INFS 590 Handouts
Wei Ding, modified by Jeff Offutt

OSF1 (osf1.gmu.edu) is the main campus computer, located in Thompson Hall. Terminal clusters are located throughout the campus, or it can be accessed through the campus dial-in network (703-4262468). Student accounts may be obtained by going to Thompson Hall.

The following instructions for compiling Java programs on OSF1 are divided into two steps. Step 1 tells you how to set up your environment to use the compiler, and Step 2 tells you how to compile Java programs. You only need to do Step 1 once.

Step 1

  1. Check if your path is correctly set. The command is
    which javac
         
    If the system responds with a name /usr/bin/javac, then path is correctly set. If the system responds with a message that there is no javac (and then gives a list of all the places it tried), then you must update path.

  2. Add /usr/bin to your search path.
    This is done by editing your .cshrc file. Look for a command such as:
    set path =. . .
         
    and modify it as follows:
    set path =. . .:/usr/bin
         

    This will allow you to access the compiler.

  3. If you want to use your special class files, you must set your environment variable called CLASSPATH to allow the compiler to find them. Suppose for illustration that they are in the directory myclasses, and directory myclasses is in your home directory. Add the lines:
    setenv CLASSPATH . . .:.:$(HOME)/myclasses
          
  4. After adding these statements, type "source .cshrc" to have them take effect (or log out and back in again).
NOTE: You only have to do Step 1 once.

Step 2

Java source files should use the extensions "java" for bodies. For example, your first program could be called "1st_prog.java". Compile an Java program with the following commands:

javac 1st_prog.java  -- javac is the Java compiler. It compiles the file 
                        1st_prog.java into the file 1st_prog.class.
java 1st_prog        -- java is Java the interpreter. It interprets the
                        bytecodes that the compiler placed in the class file.
Wei Ding
Jan, 1999