software:java:caviness

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:caviness [2018-08-10 17:21] anitasoftware:java:caviness [2021-04-27 16:21] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Projects in Java on Caviness ====== ====== Projects in Java on Caviness ======
  
-Below is 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''+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''
  
 <file java HelloWorld.java> <file java HelloWorld.java>
Line 15: Line 15:
 Check the version of the java compiler and java available on Caviness by using Check the version of the java compiler and java available on Caviness by using
  
-<code>+<code bash>
 $ javac -version $ javac -version
 $ java -version $ java -version
 </code> </code>
  
-and determine if this is acceptable for your java application to compile and create the ''HelloWorld.class'' file.  The following example is based on the user ''traine'' in workgroup ''it_css'' on Caviness using commands to create a directory ''/work/it_css/traine/java'' to store all the files associated with this example, ''salloc'' to a compute node, compile and test ''HellowWorld'', and lastly exit the compute node and return to the head node.+and determine if this is acceptable for your java application to compile and create the ''HelloWorld.class'' file.  The following example is based on the user ''traine'' in workgroup ''it_css'' on Caviness utilizing the directory ''/work/it_css/traine/java'' to store all the files associated with this example, and compiling and testing ''HellowWorld'' on the login (headnode.
  
-<code>  +<code bash>  
-[anita@login00 ~]$ workgroup -g it_css+[traine@login00 ~]$ workgroup -g it_css 
 +[(it_css:traine)@login00 ~]$ javac -version 
 +javac 1.8.0_161 
 +[(it_css:traine)@login00 ~]$ java -version 
 +openjdk version "1.8.0_161" 
 +OpenJDK Runtime Environment (build 1.8.0_161-b14) 
 +OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
 [(it_css:traine)@login00 ~]$ cd $WORKDIR/traine/java [(it_css:traine)@login00 ~]$ cd $WORKDIR/traine/java
 [(it_css:traine)@login00 java]$ cat HelloWorld.java [(it_css:traine)@login00 java]$ cat HelloWorld.java
Line 41: Line 47:
 </code> </code>
  
-If you want to run your java job in batch, then you will need a job submission script.  For this simple example, copy ''serial.qs'' from ''/opt/templates/'' on Caviness, name it ''submit.qs'', and modify it to run the ''HelloWorld'' executable.+If you want to compile on a compute node, use ''salloc --partition=devel'' to make sure you are allocated a compute node with the development tools, libraries, etc. which are needed for compilers.  It is a good idea to use a compute node especially for lengthy compiles or those requiring multiple threads to reduce the compilation time.  The following example is the same as above except the compile and test ''HelloWorld'' is done on a compute node ''r00n56'' based on the job allocated from ''salloc --partition=devel''
 + 
 +<code bash>  
 +[traine@login00 ~]$ workgroup -g it_css 
 +[(it_css:traine)@login00 ~]$ salloc --partition=devel 
 +salloc: Pending job allocation 7299417 
 +salloc: job 7299417 queued and waiting for resources 
 +salloc: job 7299417 has been allocated resources 
 +salloc: Granted job allocation 7299417 
 +salloc: Waiting for resource configuration 
 +salloc: Nodes r00n56 are ready for job 
 +[traine@r00n56 ~]$ javac -version 
 +javac 1.8.0_161 
 +[traine@r00n56 ~]$ java -version 
 +openjdk version "1.8.0_161" 
 +OpenJDK Runtime Environment (build 1.8.0_161-b14) 
 +OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode) 
 +[traine@r00n56 ~]$ cd $WORKDIR/traine/java 
 +[traine@r00n56 java]$ cat HelloWorld.java 
 +public class HelloWorld 
 +
 +  public static void main(String[] args) 
 +  { 
 +    System.out.println("Hello, World!"); 
 +  } 
 +
 +[traine@r00n56 java]$ javac HelloWorld.java 
 +[traine@r00n56 java]$ ls 
 +HelloWorld.class  HelloWorld.java 
 +[traine@r00n56 java]$ java HelloWorld 
 +Hello, World! 
 +[traine@r00n56 java]$ exit 
 +exit 
 +salloc: Relinquishing job allocation 7299417 
 +[(it_css:traine)@login00 ~]$ 
 +</code> 
 + 
 +If you want to run your java job in batch, then you will need a job submission script.  For this simple example, copy ''serial.qs'' from ''/opt/shared/templates/slurm/generic'' on Caviness, name it ''submit.qs'', and modify it to run the ''HelloWorld'' executable. Keep in mind the standard partition is available to everyone which means your job could get preempted (killed) in order to make room for workgroup-specific resources.  For testing purposes only, the partition has been modified from ''standard'' to ''devel'' for this example. Please read about all of the [[abstract:caviness:runjobs:queues|partitions]] to make sure your job is scheduled appropriately based on the limits defined for each partition. If you want to use the ''standard'' partition, please read about how to handle your job if it is preempted by using [[abstract:caviness:runjobs:schedule_jobs#Handling-System-Signals-aka- Checkpointing|Checkpointing]].
  
 <file bash submit.qs> <file bash submit.qs>
Line 88: Line 131:
 #        with the "sinfo --summarize" command. #        with the "sinfo --summarize" command.
 # #
-#SBATCH --partition=standard+#SBATCH --partition=devel
 # #
 # [EDIT] The maximum runtime for the job; a single integer is interpreted # [EDIT] The maximum runtime for the job; a single integer is interpreted
Line 137: Line 180:
 </file> </file>
  
-Now submit the job using ''sbatch submit.qs'' on the head node. The example below shows the output from the job submission and how to view the results of the job run.+Now submit the job using ''sbatch submit.qs'' on the head node after you make sure you are in your workgroup. The example below shows the output from the job submission and how to view the results of the job run.
  
-<code>+<code bash> 
 +[traine@login00 ~]$ workgroup -g it_css
 [(it_css:traine)@login00 java]$ sbatch submit.qs [(it_css:traine)@login00 java]$ sbatch submit.qs
 Submitted batch job 1231                                                                   1 Submitted batch job 1231                                                                   1
Line 149: Line 193:
 </code>  </code> 
  
-<note tip>Please review the templates for job submission scripts in ''/opt/templates'' on Caviness.  If you do not specify any resources, by default you will get the default partition, with 1 core and 1GB of memory (a simple serial job) and 20 minutes runtime on Caviness.</note>+<note tip>Please review the templates for job submission scripts in ''/opt/shared/templates'' on Caviness. There are ''README.md'' files in each subdirectory to explain the use of these templates. If you do not specify any resources, by default you will get the standard partition, with 1 core and 1GB of memory (a simple serial job) and 20 minutes runtime on Caviness.</note>
  
  • software/java/caviness.1533936074.txt.gz
  • Last modified: 2018-08-10 17:21
  • by anita