HPC with Java

Last updated July 06, 2023

There are two main versions of Java: JDK (Java Development Kit), which is provided by Oracle, and OpenJDK, which is an open source implementation of JDK.

While there are differences in licensing, both versions of Java should provide similar behavior. Refer to the documentation of the Java program you are using to determine which one is best.

0.1 Java installations

To see what Java modules area available use the module avail command:

$ module avail jdk

------------ /spack/2206/apps/lmod/linux-centos7-x86_64/gcc/11.3.0 -------------
   openjdk/1.8.0_265-b01    openjdk/11.0.15_10 (D)

------------------ /spack/apps/lmod/linux-centos7-x86_64/Core ------------------
   jdk/17.0.5

  Where:
   D:  Default Module

Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching
any of the "keys".

0.2 Memory and Heap Management

Scientific applications can easily exceed the 512MB default memory limit Java has in place. If necessary the “heap” size can be increased with the -XmxN option, with N being the desired size in bytes. For example to set a 16GB limit,

java -Xmx16g -jar file.jar

For more information please see the Java documentation: https://docs.oracle.com/en/java/javase/20/docs/specs/man/java.html