You are here

Java on DICE

Printer-friendly versionPrinter-friendly version

Supported Versions

We support multiple versions and distribution of Java (both the JVM runtime ("JRE") and development tools "JDK"). Here's a summary of the versions to be found on DICE:

DICE SL7 and Virtual DICE SL7
Version Distribution Location Notes
1.7.0 OpenJDK /usr/lib/jvm/java-1.7.0-openjdk.x86_64/
1.8.0 Sun/Oracle /usr/lib/jvm/java-1.8.0-sun/ default (where installed)
1.8.0 OpenJDK /usr/lib/jvm/java-1.8.0-openjdk.x86_64/ available on request
DICE SL6 (64-bit)
Version Distribution Location Notes
1.5.0 GCJ /usr/lib/jvm/jre-1.5.0/ For system compatibility only; not supported for development.
1.6.0 OpenJDK /usr/lib/jvm/java-1.6.0-openjdk.x86_64/ For system compatibility only.
1.6.0 Sun/Oracle /usr/lib/jvm/java-1.6.0-sun/ For system compatibility only.
1.7.0 OpenJDK /usr/lib/jvm/java-1.7.0-openjdk.x86_64/ Typically default
1.8.0 Sun/Oracle /usr/lib/jvm/java-1.8.0-sun/

The default Java version on DICE is shown above but it is subject to change over time (though typically only between semesters). However, differences between distributions are nowadays negligible for most users, and specialist requirements mean it's better for users to specify defaults individually. There are different ways to do this, depending on the way your JVM is invoked.

Checking the default version

The default java binaries are normally specified by the "alternatives" system, defined by linking /usr/bin/<appname> to each of the binaries in a given JDK directory. Note that java (provided by the JRE) and javac/javadoc/etc (provided by the JDK) can therefore be different! Your own environment including the PATH variable can override what's been set by alternatives, however.

You can discover the default version by PATH simply by executing:

$ java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel- u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

$ javac -version
javac 1.7.0_75

You can check if this is the version controlled by alternatives by running:

$ which java

(any other result but /usr/bin/java suggests you have already overridden the machine's default version).

Unfortunately the latter doesn't tell you the distribution of javac, only its version. Fortunately this can be inferred from where it's installed, using with the following, e.g.:

$ which javac | xargs readlink -f

Choosing a version

The suggested mechanism to override the default version by PATH would be to create a symbolic link in your ~/bin/ directory for each of the applications whose versions you wish to change, e.g. java or javac. Alternatively you could set aliases in your bash config, if you're mainly interested in interactive use. You could also prepend the bin JDK subdirectory to your PATH if you are likely to need alternative versions of some of the other applications bundled with Java (e.g. wsgen or javadoc).

Choosing a JVM directory

It's recommended that you avoid the precisely-versioned links (e.g. "java-1.7.0-openjdk-") unless you are testing a specific build. Automatic updates will mean that these directories will change regularly. In general, if you want to set a specific distribution or version of Java, you should use the most general link available in /usr/lib/jvm/, e.g.:

  • Version 1.8, any distribution: /usr/lib/jvm/java-1.8.0
  • Latest Sun/Oracle version: /usr/lib/jvm/java-sun
  • OpenJDK, version 1.7: /usr/lib/jvm/java-1.7.0-openjdk.x86_64 (on 64-bit systems)

...and so on.

The JAVA_HOME variable

This is not set by default, but users can add this to their ~/.brc to influence certain pieces of software. It can however be confusing to have this in conflict with the default version by PATH so it's recommended that you only set this when required, or tie them together somehow, e.g.

within .brc:
export JAVA_HOME="/usr/lib/jvm/java-1.7.0-sun/"
alias java="$JAVA_HOME/jre/bin/java"
alias javac="$JAVA_HOME/bin/javac"
alias javadoc="$JAVA_HOME/bin/javadoc"

remembering that aliases only apply to interactive shells (i.e. this will not apply to scripts you've written, with certain exceptions). If you'd like to set the default for the duration of a script, you could also do so with $PATH:

export JAVA_HOME="/usr/lib/jvm/java-1.7.0-sun/"
export PATH="$JAVA_HOME/bin:$PATH"

Per-machine defaults

Support can also change the default version of Java on a per-machine basis by manipulating the alternatives system. In general we would not do this on multi-user or lab hosts, and we don't really recommend it anywhere else (it's difficult to prevent software updates from overriding this from time to time) so we'd advise you to use other means to do this. However if you have a special requirement (or you think the default is set in error) you can contact us in the usual way.

Java 1.8 and Apache Ant

There appears to be an incompatibility between installed versions of Ant and Sun/Oracle Java 1.8 on our SL6 systems. This means that if you use JAVA_HOME to specify a default version of Java, ant will fail with an error about a missing tools.jar. This fix for this is simple, set both JAVA_HOME and ANT_HOME before use in your script or shell:

export JAVA_HOME="/usr/lib/jvm/java-sun/" # defaults to latest Sun/Oracle version of Java
export ANT_HOME="/usr/share/ant/" # this is a notional Ant home directory, you could use your own self-installed version if you'd prefer
ant [arguments...]

Java Plugins for Browsers

The Java "applet" plugin for web browsers used to be a standard part of the DICE environment, but we no longer enable it by default. The popularity of the applet in the wider web has declined significantly, while the security issues associated with its use in practice have become more apparent.

That said, there is no reason users cannot enable the plugin for specific purposes, and Support can usually provide advice on how to do this for Firefox on DICE. We recommend using the OpenJDK/IcedTea distribution (in preference to Sun/Oracle) for this purpose, as it receives more frequent security updates, but the way in which applets are handled differs significantly between versions so you may need to experiment.

Installing libraries

DICE does not provide an extensive Java package library, though it does carry a few popular packages and dependencies for mainstream software. The wider expectation seems to be that software packages will include their own library files where appropriate. Typically this is done by adding jar files to a library directory, and adding these files individually to your software's CLASSPATH, and advice on managing the Java classpath can be found from reputable sources online.

If you have a specific requirement for a Java library to be provided on all DICE machines you may request this in the usual way.

Last reviewed: 

System Status

Home dirs (AFS)
Other services
Scheduled downtime

Choose a topic