software:java:java

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:java:java [2018-01-05 10:38] anitasoftware:java:java [2021-02-24 16:36] (current) – [Details by clusters] anita
Line 1: Line 1:
 ====== Projects in Java ====== ====== Projects in Java ======
  
-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''+Using a basic Java example below, you can follow the steps 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''
  
-<file HelloWorld.java>+<file java HelloWorld.java>
 public class HelloWorld public class HelloWorld
 { {
Line 13: Line 13:
 </file> </file>
  
-<note important>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.</note> +===== Details by cluster===== 
- +  [[software:java:caviness| Caviness]] 
-On Farber and Mills, check the versions of java development by using +  [[software:java:farberFarber]] 
- +  [[software:java:mills| Mills]]
-<code> +
-$ vpkg_versions openjdk +
-</code> +
- +
-To compile and create the ''HelloWorld.class'' file, use ''javac HelloWorld.java'' on a compute node, which will create the ''HelloWorld.class'' file. The following example is based on the user ''traine'' in workgroup ''it_css'' on Farber creating a directory ''/home/work/it_css/traine/java'' to store all the files associated with this example, logging on to a compute node, loading version of openjdk using VALET, compiling and testing ''HellowWorld'' and exiting to the head node. +
- +
-<code>  +
-[farber ~]$ workgroup -g it_css +
-[(it_css:traine)@farber ~]$ cd /home/work/it_css/traine/java +
-[(it_css:traine)@farber java]$ cat HelloWorld.java +
-public class HelloWorld +
-{ +
-  public static void main(String[] args) +
-  { +
-    System.out.println("Hello, World!"); +
-  } +
-+
-[(it_css:traine)@farber java]$ qlogin +
-Your job 1392265 ("QLOGIN") has been submitted +
-waiting for interactive job to be scheduled ... +
-Your interactive job 1392265 has been successfully scheduled. +
-Establishing /opt/shared/univa/local/qlogin_ssh session to host n040 ... +
-[(it_css:traine)@n040 java]$ vpkg_devrequire openjdk/1.8.0 +
-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)@farber java]$  +
-</code> +
- +
-Back on the head node, you need a submission script to run your java job.  For this simple example, we will use a copy of ''serial.qs'' from ''/opt/templates/gridengine'' on Farber and call it ''submit.qs'', and modify it to run our ''HelloWorld'' executable. +
- +
-<file submit.qs> +
-+
-# Template:  Basic Serial Job +
-#  +
-# 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 +
-# 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 +
-+
- +
-# Add vpkg_require commands after this line: +
-vpkg_require openjdk/1.8.0 +
- +
-# Now append all of your shell commands necessary to run your program +
-# after this line: +
-java HelloWorld +
-</file> +
- +
-Now we can run our job using ''qsub submit.qs'' on the head node. The example below shows as well as commands to monitor the status of job and view results of the job run. +
- +
-<code> +
-(it_css:traine)@farber java]$ qsub submit.qs +
-Your job 1392329 ("submit.qs") has been submitted +
-[(it_css:traine)@farber 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)@farber java]$ ls +
-HelloWorld.class  HelloWorld.java  submit.qs  submit.qs.o1392329 +
-[(it_css:traine)@farber java]$ qstat +
-[(it_css:traine)@farber java]$ cat submit.qs.o1392329 +
- +
-[CGROUPSUD 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 +
-Hello, World! +
-[(it_css:traine)@farber java]$ +
-</code>  +
- +
-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.   +
  • software/java/java.1515166689.txt.gz
  • Last modified: 2018-01-05 10:38
  • by anita