====== Projects in Java on Mills ======
Below is a basic Java example and steps you can follow and apply to your ''filename.java''. Remember Unix is case sensitive so it is very important for the filename ''HelloWorld.java'' match the class name defined in the file as ''HelloWorld''.
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
All compiling for Java must be done on a compute node which means you must set your ''workgroup'' followed by ''qlogin'' to work on a compute node. Remember to use ''VALET'' to select the appropriate version of Java.
Check the versions of java development available on your cluster by using
$ vpkg_versions openjdk
and make sure you select the appropriate version to compile and create the ''HelloWorld.class'' file. The following example is based on the user ''traine'' in workgroup ''it_css'' on Mills using commands to create a directory ''/lustre/work/it_css/traine/java'' to store all the files associated with this example, ''qlogin'' to a compute node, load openjdk verison 1.8.0 using VALET, compile and test ''HellowWorld'', and lastly exit the compute node and return to the head node.
[mills ~]$ workgroup -g it_css
[(it_css:traine)@mills ~]$ cd /lustre/work/it_css/traine/java
[(it_css:traine)@mills java]$ cat HelloWorld.java
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
[(it_css:traine)@mills java]$ qlogin
Your job 2880210 ("QLOGIN") has been submitted
waiting for interactive job to be scheduled ...
Your interactive job 2880210 has been successfully scheduled.
Establishing /opt/shared/OpenGridScheduler/local/qlogin_ssh session to host n040 ...
Last login: Thu Apr 19 19:36:05 2018 from mills.mills.hpc.udel.edu
[(it_css:traine)@n040 java]$ vpkg_devrequire openjdk/1.8.0
Adding dependency `x11/RHEL6.1` to your environment
Adding package `openjdk/1.8.0` to your environment
[(it_css:traine)@n040 java]$ javac HelloWorld.java
[(it_css:traine)@n040 java]$ ls
HelloWorld.class HelloWorld.java
[(it_css:traine)@n040 java]$ java HelloWorld
Hello, World!
[(it_css:traine)@n040 java]$ exit
[(it_css:traine)@mills java]$
Once we are back on the head node, you will need a job submission script to run your java job. For this simple example, copy ''serial.qs'' from ''/opt/shared/templates/gridengine'' on Mills, name it ''submit.qs'', and modify it to run the ''HelloWorld'' executable.
#
# Template: Basic Serial Job
# Revision: $Id: serial.qs 549 2015-02-10 20:55:33Z frey $
#
# If you want an email message to be sent to you when your job ultimately
# finishes, edit the -M line to have your email address and change the
# next two lines to start with #$ instead of just #
# -m eas
# -M my_address@mail.server.com
#
# Append all of your shell commands necessary to run your program
# after this line:
vpkg_require openjdk/1.8.0
java HelloWorld
Now submit the job using ''qsub submit.qs'' on the head node. The example below shows this process including commands to monitor the status of job and view results of the job run.
(it_css:traine)@mills java]$ qsub submit.qs
Your job 1392329 ("submit.qs") has been submitted
[(it_css:traine)@mills java]$ qstat
job-ID prior name user state submit/start at queue jclass slots ja-task-ID
------------------------------------------------------------------------------------------------------------------------------------------------
1392329 0.00000 submit.qs traine qw 12/04/2017 16:54:28 1
[(it_css:traine)@mills java]$ ls
HelloWorld.class HelloWorld.java submit.qs submit.qs.o1392329
[(it_css:traine)@mills java]$ qstat
[(it_css:traine)@mills java]$ cat submit.qs.o1392329
Adding dependency `x11/RHEL6.1` to your environment
Adding package `openjdk/1.8.0` to your environment
Hello, World!
[(it_css:traine)@mills java]$
Please review the templates for job submission scripts in ''/opt/shared/templates/gridengine'' on Mills. If you do not specify any resources, by default you will get 1 core (a simple serial job) on Mills.