FreeBSD 14
Sponsored Link

OpenJDK 8 : Install2024/08/23

 

Install OpenJDK 8.

[1] Install OpenJDK 8 and run a test program.
root@dlp:~ #
pkg install -y openjdk8
root@dlp:~ #
mount -t fdescfs fdesc /dev/fd

root@dlp:~ #
mount -t procfs proc /proc

root@dlp:~ # cat >> /etc/fstab <<'EOF'
fdesc   /dev/fd         fdescfs         rw      0       0
proc    /proc           procfs          rw      0       0
EOF 

root@dlp:~ #
java -version

openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)

# verify to create test program

root@dlp:~ # cat > java_test.java <<'EOF'
class java_test {
    public static void main(String[] args) {
        System.out.println("Hello Java World !");
    }
}
EOF 

root@dlp:~ #
javac java_test.java

root@dlp:~ #
java java_test

Hello Java World !
[2] If you installed multiple version of Java from official repository, it's possible to specify the version with [JAVA_VERSION] env.
root@dlp:~ #
ll -d /usr/local/openjdk*

drwxr-xr-x  10 root wheel uarch 11 Aug 23 12:45 /usr/local/openjdk11/
drwxr-xr-x  10 root wheel uarch 11 Aug 23 12:59 /usr/local/openjdk17/
drwxr-xr-x  10 root wheel uarch 11 Aug 23 13:01 /usr/local/openjdk21/
drwxr-xr-x   9 root wheel uarch 14 Aug 23 12:41 /usr/local/openjdk8/

root@dlp:~ #
java -version

openjdk version "21.0.3" 2024-04-16
OpenJDK Runtime Environment (build 21.0.3+9-1)
OpenJDK 64-Bit Server VM (build 21.0.3+9-1, mixed mode, sharing)

root@dlp:~ #
JAVA_VERSION=8 java -version

openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)

root@dlp:~ #
JAVA_VERSION=17 javac -version

javac 17.0.11
Matched Content