Java

OpenJDK

Installation

Ubuntu
apt install openjdk-{version}-jdk-headless
AlmaLinux
dnf install java-{version}-openjdk
Arch Linux
pacman -S jdk{version}-openjdk

Examples

Fibonacci Numbers
// Fibonacci Numbers by java
public class fib_java {
    public static int fib(int n) {
        if (n < 2) {
            return n;
        } else {
            return fib(n-2) + fib(n-1);
        }
    }
    public static void main(String[] args) {
        int n = Integer.parseInt(args[0]);
        System.out.println(fib(n));
    }
}

/*
    example
        compile by OpenJDK:
            javac fib_java.java
        run by OpenJDK:
            java fib_java 39
*/