How to run Java on maya

Introduction

On this page we’ll see how to use Java on the maya 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 maya

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

[user@nXXX]$ which java
/usr/bin/java
[user@nXXX]$ javac -version
javac 1.7.0_75
[user@nXXX]$ 

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.

How does all of this relate to maya? WELL, if you wish to run a Java program on a compute node that has a lot of RAM, your job needs to have at least 1/4 of those resources allocated … this is hard to do. For one, we have rules that don’t let you do it in certain cases and also, requesting more resources means that slurm will have a hard time scheduling your job.

So what can you do?

 

Redefine _JAVA_OPTIONS variable

In your sbatch 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.