Skip to content

Java

Java is a general-purpose computer programming language that is concurrent, class-based and object-oriented. Compiled Java code can run on all platforms that support Java without the need for recompilation.

Java is available as a module on Apocrita.

Java versions

Due to licensing restrictions, Oracle versions of Java are not available on the cluster. Only OpenJDK is provided and supported. Please ensure your applications are compatible with OpenJDK.

Usage

To run Java, simply load the openjdk module.

module load openjdk

To check what version of Java is being used by your current session, run java -version.

To compile your code, use javac

javac HelloWorld.java

and java to run it

java HelloWorld

Java memory usage

Java tends to allocate large amounts of virtual memory, while only using a small amount. To avoid a huge amount of virtual memory being allocated on compute nodes the MALLOC_ARENA_MAX variable could be set.

Note that the UGE scheduler kills jobs after the real memory used exceeds the h_vmem value requested in your job, rather than virtual memory. In your job emails, the real memory used is shown by the Max rss value.

As MALLOC_ARENA_MAX is an environment variable, you can either unset it or override its value before the execution of your application if necessary, e.g.

export MALLOC_ARENA_MAX=1

Example job

Serial job

Here is an example job running on 4 cores.

#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 4
#$ -l h_rt=1:0:0
#$ -l h_vmem=2G

module load openjdk

java Example

References