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
PBSscript, load java with
module load java/1.8.0_152, you can use
module avail javato see what versions of java are available.
- Make sure to
runjava as you normally would. Include the compile and run steps after the
#PBSdirectives in the
- 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 cd $PBS_O_WORKDIR module load java/1.8.0_152 javac helloWorld.java java helloWorld
#PBSdirectives are standard, requesting just 1 minute of walltime and 1 node with 2 cores. More on
#PBSdirectives can be found in the PBS guide
$PBS_O_WORKDIRis 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_152loads 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.javais the line that compiles the java file, so it can be run
java helloWorldruns the program
Part 2: Submit Job and Check Status¶
- Make sure you're in the dir that contains the
PBSScript as well as the
- Submit as normal, with
qsub <pbs script name>. In this case
- 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
PBSscript, you should see a
helloWorldJava.outfile, which contains the results of the job. Use
cat helloWorldJava.outor open the file in a text editor to take a look.
helloWorldJava.outshould 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.