Java

Several Java Development Kits are installed in /usr/local/Java. Older versions are available for applications that require them. The latest version of java is symlinked to /usr/local/java.

When compiling against Java, load the appropriate java module file, for example:
module load java/1.8.0_92

This will set the appropriate JAVA_HOME, PATH and LD_LIBRARY_PATH environment variables.

Executing a Jar file with Java

You may run a jar file directly using the -jar flag:

java [options] -jar jarfile
Common Java Options

All java-based applications can utilize these options.

Specifying Memory

Including these options will configure the amount of memory required to run the java-based application. [size] can be defined in kilobytes (e.g. 5k), megabytes (10m), or gigabytes (8g).

It is very common to include -Xmx4g with calls to java. This requires that 4GB of memory is available to the java instance.

Specifying Scratch Space

Java-based applications will very often require a scratch space for creating temporary files during execution. By default, this is set to /tmp. Unfortunately, many genomic java applications require much more scratch space than is available in /tmp. Worse, running multiple instances of java on a single node may fill up /tmp. In this case, including the option

will configure java to use [TMPDIR] as a scratch space. Typically, this can be set to /lscratch/$SLURM_JOB_ID:

java -Djava.io.tmpdir=/lscratch/$SLURM_JOB_ID -jar jarfile

Please see information on allocting lscratch here.

Disabling X11 Display and Keyboard Interaction

Some java applications fail to run under batch conditions because an X11 display is not available, or no keyboard is detected, even though the command should run in batch or in the background. For these situations, running java in so-called "headless" mode may allow batch runs:

java -Djava.awt.headless=true -jar jarfile

For more information about how to configure java-based applications, type

java --help

at the prompt, or go to http://www.oracle.com/technetwork/java.

Specifying the Number of Garbage Collection (GC) threads.

By default, the Java virtual machine (JVM) will calculate the available number of CPUs at runtime. This default behaviour can easily consume most of the available CPUs. In most cases, you should use the following option to limit the number of threads the JVM will use for garbage collection:

This will limit the number of parallel garbage collection threads to 2. Adjust the value as needed for your application.

Specifying the Server VM

The Server VM is intended for long-running Java applications. It is optimized and tuned to maximize peak operating speed. For long running Java processes, it is recommended to use the following option:

Respecting compute node proxy settings

Biowulf compute nodes are behind a firewall and must be configured to use proxy servers to access the internet. This configuration is not respected by default within the Java environment. Set the flag -Djava.net.useSystemProxies to true to access the internet from within Java.

java -Djava.net.useSystemProxies=true -jar jarfile

In many instances, you can set an environment variable to the same effect.

export JAVA_TOOL_OPTIONS="-Djava.net.useSystemProxies=true"