Skip to content
System Status: All systems are operational • Services are available and operational.
Click for detailed status

Java

Java is a high-level, general-purpose, memory-safe, object-oriented programming language. It is intended to let programmers write once, run anywhere.

Java on Euler

On Euler the following versions are available via modules:

Version Module command
21.0.3 module load stack/2024-06 openjdk/21.0.3_9
17.0.8.1 module load stack/2024-06 openjdk/17.0.8.1_1
11.0.20.1 module load stack/2024-06 openjdk/11.0.20.1_1
8u141-b15 module load stack/2024-06 jdk/8u141-b15

Example program

Create a file hello.java, with the content:

class Hello
{
    public static void main(String[] args)
    {
        System.out.println("Hello, World!");
    }
}

Bring java and javac (the java compiler) to the command line with:

module load stack/2024-06 openjdk/21.0.3_9

Compile the program hello.java:

javac hello.java

which produces a file Hello.class. Then run the program with:

java Hello

and the program should print:

Hello, World!

to your terminal.