Next revision | Previous revision |
software:java:mills [2018-08-10 16:27] – created anita | software:java:mills [2021-04-27 16:21] (current) – external edit 127.0.0.1 |
---|
====== Projects in Java ====== | ====== 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''. | 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''. |
</code> | </code> |
| |
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 Farber using commands to create a directory ''/home/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. | 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. |
| |
<code> | <code> |
[farber ~]$ workgroup -g it_css | [mills ~]$ workgroup -g it_css |
[(it_css:traine)@farber ~]$ cd /home/work/it_css/traine/java | [(it_css:traine)@mills ~]$ cd /lustre/work/it_css/traine/java |
[(it_css:traine)@farber java]$ cat HelloWorld.java | [(it_css:traine)@mills java]$ cat HelloWorld.java |
public class HelloWorld | public class HelloWorld |
{ | { |
} | } |
} | } |
[(it_css:traine)@farber java]$ qlogin | [(it_css:traine)@mills java]$ qlogin |
Your job 1392265 ("QLOGIN") has been submitted | Your job 2880210 ("QLOGIN") has been submitted |
waiting for interactive job to be scheduled ... | waiting for interactive job to be scheduled ... |
Your interactive job 1392265 has been successfully scheduled. | Your interactive job 2880210 has been successfully scheduled. |
Establishing /opt/shared/univa/local/qlogin_ssh session to host n040 ... | 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 | [(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 | Adding package `openjdk/1.8.0` to your environment |
[(it_css:traine)@n040 java]$ javac HelloWorld.java | [(it_css:traine)@n040 java]$ javac HelloWorld.java |
Hello, World! | Hello, World! |
[(it_css:traine)@n040 java]$ exit | [(it_css:traine)@n040 java]$ exit |
[(it_css:traine)@farber java]$ | [(it_css:traine)@mills java]$ |
</code> | </code> |
| |
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/templates/gridengine'' on Farber, name it ''submit.qs'', and modify it to run the ''HelloWorld'' executable. | 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. |
| |
<file bash submit.qs> | <file bash submit.qs> |
# | # |
# Template: Basic Serial Job | # Template: Basic Serial Job |
# | # Revision: $Id: serial.qs 549 2015-02-10 20:55:33Z frey $ |
# Change the following to #$ and set the amount of memory you need | |
# per-slot if you're getting out-of-memory errors using the | |
# default: | |
# -l m_mem_free=2G | |
# | # |
# If you want an email message to be sent to you when your job ultimately | # If you want an email message to be sent to you when your job ultimately |
# | # |
| |
# Add vpkg_require commands after this line: | # Append all of your shell commands necessary to run your program |
| # after this line: |
vpkg_require openjdk/1.8.0 | vpkg_require openjdk/1.8.0 |
| |
# Now append all of your shell commands necessary to run your program | |
# after this line: | |
java HelloWorld | java HelloWorld |
</file> | </file> |
| |
Now submit the job using ''qsub submit.qs'' on the head node. The example below shows this process incuding commands to monitor the status of job and view results of the job run. | 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. |
| |
<code> | <code> |
(it_css:traine)@farber java]$ qsub submit.qs | (it_css:traine)@mills java]$ qsub submit.qs |
Your job 1392329 ("submit.qs") has been submitted | Your job 1392329 ("submit.qs") has been submitted |
[(it_css:traine)@farber java]$ qstat | [(it_css:traine)@mills java]$ qstat |
job-ID prior name user state submit/start at queue jclass slots ja-task-ID | 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 | 1392329 0.00000 submit.qs traine qw 12/04/2017 16:54:28 1 |
[(it_css:traine)@farber java]$ ls | [(it_css:traine)@mills java]$ ls |
HelloWorld.class HelloWorld.java submit.qs submit.qs.o1392329 | HelloWorld.class HelloWorld.java submit.qs submit.qs.o1392329 |
[(it_css:traine)@farber java]$ qstat | [(it_css:traine)@mills java]$ qstat |
[(it_css:traine)@farber java]$ cat submit.qs.o1392329 | [(it_css:traine)@mills java]$ cat submit.qs.o1392329 |
| Adding dependency `x11/RHEL6.1` to your environment |
[CGROUPS] UD Grid Engine cgroup setup commencing | |
[CGROUPS] Setting 1073741824 bytes (vmem none bytes) on n038 (master) | |
[CGROUPS] with 1 core = | |
[CGROUPS] done. | |
Adding package `openjdk/1.8.0` to your environment | Adding package `openjdk/1.8.0` to your environment |
Hello, World! | Hello, World! |
[(it_css:traine)@farber java]$ | [(it_css:traine)@mills java]$ |
</code> | </code> |
| |
<note tip>Please review the templates for job submission scripts in ''/opt/templates/gridengine'' on Farber and Mills. If you do not specify any resources, by default you will get 1 core and 1GB of memory (a simple serial job) on Farber.</note> | <note tip>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.</note> |
| |