ติดตั้ง JDK บน Windows

ดาว์นโหลด jdk 11 มาแบบ msi จะได้ไฟล์ชื่อ microsoft-jdk-11.0.23-windows-x64.msi

ตอนติดตั้งก็เลือกให้ set JAVA_HOME ด้วย

ติดตั้งเสร็จก็ตรวจสอบ

> java --version
openjdk 11.0.23 2024-04-16 LTS
OpenJDK Runtime Environment Microsoft-9394293 (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM Microsoft-9394293 (build 11.0.23+9-LTS, mixed mode, sharing)
> javac --version
javac 11.0.23
> echo %JAVA_HOME%
C:\Program Files\Microsoft\jdk-11.0.23.9-hotspot\

ติดตั้ง Java บน AlmaLinux 8

Step 1. First, let’s start by ensuring your system is up-to-date.

$ sudo dnf update
$ sudo dnf install epel-release

Install Java 11

$ sudo dnf install java-11-openjdk

Install Java 8

$ sudo dnf install java-1.8.0-openjdk

Once the Java installation is complete, run the below command to verify the Java version:

$ java -version
openjdk version "11.0.15" 2022-04-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)

Step 3. Set Default Java Version on AlmaLinux.

$ sudo alternatives --config java

Step 4: Set the JAVA_HOME environment variable (optional)

$ type java
java is hashed (/usr/bin/java)

Set the variable with the following command:

export JAVA_HOME=/usr