UMBC logo
UMBC High Performance Computing Facility
How to run Java on tara

Introduction

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

Currently the system-default Java is the mosy up-to-date

[araim1@tara-fe1 java]$ which javac
/usr/bin/javac
[araim1@tara-fe1 java]$ javac -version
javac 1.6.0_26
[araim1@tara-fe1 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@tara-fe1 java_hello]$ javac HelloWorld.java 
[araim1@tara-fe1 java_hello]$ ls
HelloWorld.class  HelloWorld.java
[araim1@tara-fe1 java_hello]$ java HelloWorld
Hello World!
[araim1@tara-fe1 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@tara-fe1 java]$ sbatch run.slurm 
Submitted batch job 99868
[araim1@tara-fe1 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@tara-fe1 java_hello]$ cat slurm.out 
Hello World!
[araim1@tara-fe1 java_hello]$ cat slurm.err 
[araim1@tara-fe1 java_hello]$