Install OpenJDK 11 (win , mac, linux)

OpenJDK 11 is an open-source build of the Java Development Kit (JDK: kit for developing Java programs ),  under the [GNU General Public License, version 2,with the Classpath Exception]. We will not explain in this post the difference between OpenJDK and OracleJDK it’s a long story (don’t worry there is few changes between them). but just keep in mind that there is 2 versions: open source version (OpenJDK) and commercial version of JDK (Oracle JDK)

NB: Big thanks for Oracle to participate in maintaining the openSource JDK version beside the Oracle JDK. The SUN still shine! I guess Java is in good hands !

Well will not focus on Oracle JDK (commercial version) but you can download it from this link: https://www.oracle.com/technetwork/java/javase/downloads/index.html

so lets install Open Jdk

I) Installation on Windows

  • From the link https://jdk.java.net/11/ download the zip of Windows / x64 extract it in <your_java_home> for example in my case   c:\tools\java\jdk-11.0.1
  • Add the <your_java_home>\bin to your Path : with right mouse button click on your pc icon then select properties

 Select  Advanced system settings.

press  Environment Variables button .

select Path variable , click on edit and add <your_java_home>\bin, press ok

 

NB: It’ s nice to create JAVA_HOME environment variable and has <your_java_home> as value, this is used by most of tools and API using JDK.

NB: There is 2 locations of environment variables  local user location (blue rectangle) and system location (red rectangle), add java bin directory to both Path variables

 

  • Test OpenJDK installation, open cmd.exe and type :

java -version

example of result :

openjdk version “11.0.1” 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

II)Install on Linux Centos.

  • From the link https://jdk.java.net/11/ download the tar.gz of Linux / x64 tar.gz extract it in <your_java_home> for example in my case  /opt/java/jdk-11.0.1

sudo tar xvzf openjdk-11.0.1_linux-x64_bin.tar.gz -C /opt/java/

  • Add the <your_java_home>\bin to your Path : I will use my .bash_profile file to get bin directory commands load in the login in linux session

vi ~/.bash_profile

then make following lines in end of file

PATH=$PATH:/opt/java/jdk-11.0.1/bin
export PATH

  • exit from linux session and reconnect again and execute:

java -version

example of result :

openjdk version “11.0.1” 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mod

III) Install on Mac OS ( test for jdk-11.0.2).

  • From the link  https://jdk.java.net/11/download the tar.gz of macOS/x64 tar.gz extract it in <your_java_home>for example in my case  /opt/java/jdk-11.0.2.jdk

sudo tar xvzf openjdk-11.0.2_osx-x64_bin.tar  -C /opt/java/

  • Add the /opt/java/jdk-11.0.2.jdk/Contents/Home/bin
     to your /etc/paths  to get bin directory commands load in start or macOS you can use vi command likeÂ

sudo vi /etc/paths

then add the following line:

/opt/java/jdk-11.0.2.jdk/Contents/Home/bin

  • restart your Mac OS  and execute:

java -version

example of result :

openjdk version “11.0.2” 2018-10-16

OpenJDK Runtime Environment 18.9 (build 11.0.2+7)

OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode)