Java

Java is available on the cluster. Activate java by loading the Java module

$ ml Java

Note that the Java module must be loaded on the compute nodes as well, in order to run java on compute nodes.

Check for java version and path

$ java -version
$ which java

With the module loaded, not only the runtime environment (JRE), but also the development environment (JDK) with the compiler is available.

$ javac -version
$ which javac

Java applications may use MPI for inter-process communication, in conjunction with Open MPI. Read more on http://www.open-mpi.org/faq/?category=java. This functionality is currently not supported on Anselm cluster. In case you require the java interface to MPI, please contact cluster support.

Java With OpenMPI

Because there is an increasing interest in using Java for HPC. Also, MPI can benefit from Java because its widespread use makes it likely to find new uses beyond traditional HPC applications.

The Java bindings are integrated into Open MPI starting from the v1.7 series. Beginning with the v2.0 series, the Java bindings include coverage of MPI-3.1.

Example (Hello.java)

import mpi.*;

class Hello {
    static public void main(String[] args) throws MPIException {


        MPI.Init(args);

        int myrank = MPI.COMM_WORLD.getRank();
        int size = MPI.COMM_WORLD.getSize() ;
        System.out.println("Hello world from rank " + myrank + " of " + size);

        MPI.Finalize();
    }
}
$ ml Java/1.8.0_144
$ ml OpenMPI/1.8.0_144
$ mpijavac Hello.java
$ mpirun java Hello
Hello world from rank 23 of 28
Hello world from rank 25 of 28
Hello world from rank 0 of 28
Hello world from rank 4 of 28
Hello world from rank 7 of 28
Hello world from rank 8 of 28
Hello world from rank 11 of 28
Hello world from rank 12 of 28
Hello world from rank 13 of 28
Hello world from rank 18 of 28
Hello world from rank 17 of 28
Hello world from rank 24 of 28
Hello world from rank 27 of 28
Hello world from rank 2 of 28
Hello world from rank 3 of 28
Hello world from rank 1 of 28
Hello world from rank 10 of 28
Hello world from rank 14 of 28
Hello world from rank 16 of 28
Hello world from rank 19 of 28
Hello world from rank 26 of 28
Hello world from rank 6 of 28
Hello world from rank 9 of 28
Hello world from rank 15 of 28
Hello world from rank 20 of 28
Hello world from rank 5 of 28
Hello world from rank 21 of 28
Hello world from rank 22 of 28