UMBC logo
UMBC High Performance Computing Facility
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 system-default Java is the mosy up-to-date

[jongraf1@maya-usr2 Java]$ which java
/usr/bin/java
[jongraf1@maya-usr2 Java]$ javac -version
javac 1.7.0_75
[jongraf1@maya-usr2 Java]$ 

Example batch script

We'll write a simple Java program that says "hello".
class HelloWorld
{  
    public static void main(String args[])
    {
        System.out.println("Hello World!");
    }
}

Download: ../code/java_hello/HelloWorld.java
We can compile and run on the user node to test
[araim1@maya-usr1 java_hello]$ javac HelloWorld.java 
[araim1@maya-usr1 java_hello]$ ls
HelloWorld.class  HelloWorld.java
[araim1@maya-usr1 java_hello]$ java HelloWorld
Hello World!
[araim1@maya-usr1 java_hello]$ 
We can launch it with a standard SLURM script.
#!/bin/bash
#SBATCH --job-name=hello_java
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=develop

java HelloWorld

Download: ../code/java_hello/run.slurm
Now we launch the job
[araim1@maya-usr1 java]$ sbatch run.slurm 
Submitted batch job 99868
[araim1@maya-usr1 java_hello]$ squeue
  JOBID PARTITION     NAME     USER ST       TIME  NODES QOS     NODELIST(REASON)
  99868   develop hello_ja   araim1  R       0:02      1 normal  n1
[araim1@maya-usr1 java_hello]$ cat slurm.out 
Hello World!
[araim1@maya-usr1 java_hello]$ cat slurm.err 
[araim1@maya-usr1 java_hello]$