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
1.8.0 module load stack/2024-06 jdk/8u141-b15

Hello world

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, compile the program hello.java, which produces a file Hello.class, then run the program

module load stack/2024-06 openjdk/21.0.3_9
javac hello.java
java Hello
You should see

Hello, World!