Skip to Main Content

How to Run Java Programs on taki


On this page we’ll see how to use Java on the cluster. Before proceeding, make sure you’ve read the How To Run tutorial first. Java is a popular object-oriented programming language used in general-purpose computing.

Java on taki

Currently the most up to date version of Java is the system default:

[reetam1@taki-usr1 ~]$ which java
[reetam1@taki-usr1 ~]$ javac -version
Picked up _JAVA_OPTIONS: -Xmx2G
javac 1.8.0_181
[reetam1@taki-usr1 ~]$

In order to execute Java programs, it is important to understand that Java relies on the Java Virtual Machine (JVM) to execute the Java bytecode (precomputed *.class files). The JVM is responsible for the object heap and therefore the infamous java garbage collection utilities. Java Garbage Collection relies heavily on processor power/utilization. More memory means that Garbage Collection takes longer and works harder at freeing memory. For optimal performance, the general rule is to use a quarter of physical memory. This general rule has been set as default in the JVM Java Options.

Redefine _JAVA_OPTIONS variable

In your slurm script, throw in the following line that will override the JVM default and ask only for an amount of memory that you specify:

export _JAVA_OPTIONS=”-Xmx1G”

This would configure the JVM to only request 1Gb (“1G”). Alternatively, “512M” for 0.5Gb and so on.