Updated 2021-05-17

Run Java on the Cluster


  • This guide will focus on running java normally. Mpj (mpj express) is available on the cluster if you wish to run Java in parallel.


  • In the PBS script, load java with module load java/1.8.0_152, you can use module avail java to see what versions of java are available.
  • Make sure to compile and run java as you normally would. Include the compile and run steps after the #PBS directives in the PBS script.
  • As always, make sure your java program and any files needed are all in the same folder.

Walkthrough: Run Java on the Cluster

  • This walkthrough will use a simple Java program that prints "Hello World"
  • Java program can be found here
  • PBS script can be found here
  • You can transfer the files to your account on the cluster to follow along. The file transfer guide may be helpful.

Part 1: The PBS Script

#PBS -N helloWorldJava
#PBS -A [Account] 
#PBS -l nodes=1:ppn=2
#PBS -l pmem=2gb
#PBS -l walltime=1:00
#PBS -q inferno
#PBS -j oe
#PBS -o helloWorldJava.out

module load java/1.8.0_152
javac helloWorld.java
java helloWorld

  • The #PBS directives are standard, requesting just 1 minute of walltime and 1 node with 2 cores. More on #PBS directives can be found in the PBS guide
  • $PBS_O_WORKDIR is simply a variable that represents the directory you submit the PBS script from. Make sure the java script you want to run (in this case, helloWorld.java) is in the same directory you put the PBS script.
  • Output Files will also show up in this dir as well (in this case, the helloWorld.class file)
  • module load java/1.8.0_152 loads the 1.8.0 version of Java. To see what Java versions are available, run module avail java, and load the one you want
  • javac helloWorld.java is the line that compiles the java file, so it can be run
  • java helloWorld runs the program

Part 2: Submit Job and Check Status

  • Make sure you're in the dir that contains the PBS Script as well as the java program
  • Submit as normal, with qsub <pbs script name>. In this case qsub java.pbs
  • Check job status with qstat -t 22182721, replacing the number with the job id returned after running qsub
  • You can delete the job with qdel 22182721 , again replacing the number with the jobid returned after running qsub

Part 3: Collecting Results

  • In the directory where you submitted the PBS script, you should see a helloWorldJava.out file, which contains the results of the job. Use cat helloWorldJava.out or open the file in a text editor to take a look.
  • helloWorldJava.out should look like this:
Job name:   helloWorldJava
Queue:      inferno
End PBS Prologue Tue Sep  4 16:33:42 EDT 2018
Hello World
Begin PBS Epilogue Tue Sep  4 16:33:44 EDT 2018
Job ID:     22254724.shared-sched.pace.gatech.edu
  • After the result files are produced, you can move the files off the cluster, refer to the file transfer guide for help.
  • Congratulations! You successfully ran a Java program on the cluster.