Skip to content Skip to navigation

Setting your java version

To support the various needs of Computer Science courses, multiple versions of Sun java are installed on desktop , laboratory and server machines. The java programs located in /usr/local/bin/ will autoselect a version for you so long as /usr/local/bin/ is first in your PATH enviornmental variable (type "which java" and see if /usr/local/bin/java is returned). You can also manually set your prefered java version.

To see what your current java version settings are, type /usr/local/bin/java -version at the prompt.

We have two methods for changing your version of java to something that suits your needs.

  1. The first method is setting a JAVAVERSION environmental variable to the explicit version you need. For example...
    • Under csh or tcsh:
      • add setenv JAVAVERSION {version} to your .cshrc file (replace {version} with a number such as 1.5)
      • or type setenv JAVAVERSION {version} at the prompt
        For example: setenv JAVAVERSION 1.5 would allow you to run java 1.5
    • Under ksh:
      • add the following two lines to your .profile
        JAVAVERSION={version}
      • export JAVAVERSION
        (replace {version} with a number such as 1.5)
      • or type export JAVAVERSION={version} at the prompt
        For example: export JAVAVERSION=1.5 would allow you to run java 1.5
    • Under bash:  (see directions for ksh)
  2. Alternatively, instead of setting {version} to a number you can set it to one of the following words new , current, or old via the same syntax as above. As we upgrade our systems the version associated with these names will change.

When you run java (or javac, jdb, appletviewer, etc.), you will be running the version specified by the JAVAVERSION variable.  If this variable is not set you will be running the default version of java. This is identical to setting JAVAVERSION to current.