Running Java Jobs

Quickstart: Java

To use Java on the HTC system, we recommend that you use the Java Development Kit (JDK).

  1. Obtain a copy of the pre-compiled JDK for “Linux/x64” from https://jdk.java.net/.

  2. Include the JDK .tar.gz file in your submit file with the list of files to be transferred:

    transfer_input_files = openjdk-22_linux-x64_bin.tar.gz, program.jar
    
  3. Include instructions for using the JDK in your executable file:

    #!/bin/bash
    
    tar -xzf openjdk-22_linux-x64_bin.tar.gz
    export JAVA_HOME=$PWD/jdk-22
    export PATH=$JAVA_HOME/bin:$PATH
    
    java -jar program.jar
    

More information

To obtain your copy of the Java Development Kit (JDK), go to https://jdk.java.net/. Click the link for the JDK that is “Ready for use”. There will be a download link “tar.gz” under the “Builds” section for “Linux/x64”. You can then either (a) right-click the download link and copy the link address, sign in to the submit server, and use the wget command with that link, or (b) click the link to download to your computer, then manually upload the file from your computer to the submit server.

The example above uses file names for JDK 22 as of 2024-04. Be sure to change the file names for the version that you actually use. We recommend that you test and explore your setup using an interactive job.

Executable

A bash .sh file is used as the executable file in order to unpack and set up the JDK environment for use by your script. Here is the executable from the section with comments:

#!/bin/bash

# Decompress the JDK
tar -xzf openjdk-22_linux-x64_bin.tar.gz

# Add the new JDK folder to the bash environment
export JAVA_HOME=$PWD/jdk-22
export PATH=$JAVA_HOME/bin:$PATH

# Run your program
java -jar program.jar
HTC Guides