Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. The language derives much of its syntax from C and C++, but it has fewer low-level facilities.
The Java home page is at http://www.java.com.
All versions of Java on NeSI clusters have been made available by their respective owners at no cost under a limited, closed-source licence. The full licence terms and conditions for any given version of Java can be found by following the directions in
Example script for Mahuika
#!/bin/bash -e #SBATCH --job-name MyMultithreadedJavaJob
#SBATCH --time 1:00:00 # 1 hour walltime limit #SBATCH --cpus-per-task 8 # 8 CPU cores for 8 Java threads #SBATCH --mem 4G # 4 GB of memory module load Java/1.8.0_144 java -Xmx3g -D
Memory management and the -Xmx option
It is important to let the Java virtual machine know how much memory it is allowed to use. The main way this is done is via the
-Xmx option, which sets the maximum amount of heap space that it can use.
As a first approximation, we recommend setting the
-Xmx option to 75% of the requested memory. For example, if your job asks the scheduler for 32 GB of memory, you should provide the Java executable with
-Xmx24g, which will cap its heap usage to 24 GB, leaving at least 6 GB for its stack and any other overheads.
Java programs which use temporary files can (and should) generally be persuaded to use $TMPDIR rather than just the default of
/tmp by being given the option
-Djava.io.tmpdir=$TMPDIR. TMPDIR is automatically removed at the end of the job.