Header Ads

Installation of Java JDK on Ubuntu | Installation of Java JDK on Windows | Installation of Java JDK on MacOS

Installation of Java JDK on Ubuntu | Installation of Java JDK on Windows | Installation of Java JDK on MacOS



This article is totally related to installation of java JDK on Ubuntu,Windows and MacOS.
Article shows you step by step installation.So go through it and enjoy java programming!!! 

Installation on Ubuntu 18.04

Install OpenJDK

Let’s begin by installing Java OpenJDK 13 on Ubuntu 18.04. First, we need to check and see if we have Java installed using the following command.

root@host:~# java -version Command 'java' not found, but can be installed with: apt install default-jre apt install openjdk-11-jre-headless apt install openjdk-8-jre-headless root@host:~#

This indicates that Java is not currently installed.

Download Java SDK 13

Our next step includes downloading the Java SDK (or software developer kit). We will accomplish this by using the wget command. 
root@host:~# wget https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_linux-x64_bin.tar.gz --2020-04-04 15:41:57-- https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_linux-x64_bin.tar.gz Resolving download.java.net (download.java.net)... 23.39.73.139 Connecting to download.java.net (download.java.net)|23.39.73.139|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 195812001 (187M) [application/x-gzip] Saving to: 'openjdk-13.0.2_linux-x64_bin.tar.gz' openjdk-13.0.2_linu 100%[==================>] 186,74M 2,34MB/s in 72s 2020-04-04 15:43:10 (2,58 MB/s) - 'openjdk-13.0.2_linux-x64_bin.tar.gz' saved [195812001/195812001] root@host:~#



Working Directory

Next, we will create a working directory where Java will reside, change directories into that folder, copy the downloaded file into that directory, and finally, extract the tar.gz file into its directory.

root@host:~# mkdir /usr/java root@host:~# root@host:~# cd /usr/java root@host:/usr/java# root@host:/usr/java# cp /root/openjdk-13.0.2_linux-x64_bin.tar.gz openjdk-13.0.2_linux-x64_bin.tar.gz root@host:/usr/java# root@host:/usr/java# sudo tar -xzvf openjdk-13.0.2_linux-x64_bin.tar.gz ... root@host:/usr/java#

Set Environment Variables

The Set Environment Variables step is necessary because when using Java, Ubuntu needs to know where the program is located to run it from, and which Java version to use by default. To modify this, we will use the nano text editor. First, open the file in Nano.

root@host:/usr/java# nano /etc/profile root@host:/usr/java#

Next, scroll to the bottom of the file and paste this information.

# Java 13 JAVA_HOME=/usr/java/jdk-13.0.2 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export JRE_HOME export PATH

Finally, we press ctrl + O + Y + Enter then ctrl + X + Enter to save and close the file.

Finishing the Configuration Setup

Our last step involves updating the information in our system to point the new program and its options. In this case, we update the information regarding the Java installation.

root@host:/usr/java# update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-13.0.2/bin/java" 1 update-alternatives: using /usr/java/jdk-13.0.2/bin/java to provide /usr/bin/java (java) in auto mode root@host:/usr/java# root@host:/usr/java# update-alternatives --config java There is only one alternative in link group java (providing /usr/bin/java): /usr/java/jdk-13.0.2/bin/java Nothing to configure. root@host:/usr/java# root@host:/usr/java# update-alternatives --config javac There is only one alternative in link group javac (providing /usr/bin/javac): /usr/java/jdk-13.0.2/bin/javac Nothing to configure. root@host:/usr/java#


Version Check

As a final verification, we can check the installation and the version using the following command.

root@host:/usr/java# java -version openjdk version "13.0.2" 2020-01-14 OpenJDK Runtime Environment (build 13.0.2+8) OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing) root@host:/usr/java#

Here, we have installed Java on Ubuntu

Installation on Windows 10.

In order to install the Windows version of Java, we need to visit the official Java website and download the Windows executable. Once at the site, the licensing options are outlined in green. It states “The new Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle JDK licenses. The new license permits certain uses, such as personal use and development use, at no cost — but other uses authorized under prior Oracle JDK licenses may no longer be available. Please review the terms carefully before downloading and using this product.

Commercial license and support is available with a low cost Java SE Subscription.” We will scroll down to see the available downloads.


We will be downloading the jdk-13.0.2_windows-x64_bin.exe version.


After we click on the selected version, we must accept the user agreement.




Once the download completes, run the executable.






Click next and agree with the selected folders by default. Click Close when complete.






Setup Environment Variables

JAVA_HOME is a variable that points to the directory in which Java is installed. Programs use it to determine where Java is located.
Click on the keyboard combination Win+R, the Run window will pop up, and we then enter the command control / name Microsoft.system.



Next, select Advanced system settings




Now, click on Environment Variables.



Now, choose Path, and then click on New.



Enter the name: JAVA_HOME. Next, specify the path. If you selected the default path, you will see the path C:\Program Files\Java\jdk-13.0.2




Next, select PATH edit.



Then, we click New and enter the following.
%JAVA_HOME%\bin



And click OK in all open windows.
Now, to verify everything, we will open the run console with the Windows+r command and enter cmd and then press enter.



Now, we will enter the following command to check if everything works as expected

C:\Users\User>echo %JAVA_HOME% C:\Program Files\Java\jdk-13.0.2 C:\Users\User>


Next, we will check the Java version using the following command.

C:\Users\User>java -version java version "13.0.2" 2020-01-14 Java(TM) SE Runtime Environment (build 13.0.2+8) Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing) C:\Users\User>



Good Work :)

Here, we have installed Java on Windows

Installation on MacOS

There are several options on how to do it. We can do the same way as we did in Ubuntu or Windows. Since we are installing the JDK version for developers, and in the future we will need to be able to install some programs, we will install through the console. We launch the console. If you do not know how to enter the terminal, open the directory below, then in Applications -> Utilities -> Terminal.


For macOS we will use the SDKMAN utility, it is often used when you need to install several versions and configure it, SDKMAN does everything by itself. Conveniently, this installation can be used on macOS and Ubuntu.

Add SDKMAN Repository

In the initial step, we will install the SDKMAN repository.
curl -s "https://get.sdkman.io" | bash user-iMac:~ user$ curl -s "https://get.sdkman.io" | bash Now attempting installation... Looking for a previous installation of SDKMAN... Looking for unzip... Looking for zip... Looking for curl... Looking for sed... Installing SDKMAN scripts... Create distribution directories... Getting available candidates... Prime the config file... Download script archive... #####################################################100.0% Extract script archive... Install scripts... Set version to 5.7.4+362 ... Attempt update of login bash profile on OSX... Added sdkman init snippet to /Users/ellen/.bash_profile Attempt update of zsh profile... Updated existing /Users/ellen/.zshrc All done! Please open a new terminal, or run the following in the existing one: source "/Users/ellen/.sdkman/bin/sdkman-init.sh" Then issue the following command: sdk help Enjoy!!! user-iMac:~ user$





Set Environment Variable

Next, we will set the environment variable.

user-iMac:~ user$ source "$HOME/.sdkman/bin/sdkman-init.sh" user-iMac:~ user$

Now, we can check to ensure SDKMAN is installed.

user-iMac:~ user$ sdk version SDKMAN 5.7.4+362 user-iMac:~ user$

Now, we can review a list of Java versions.

user-iMac:~ user$ sdk list java =========================================================== Available Java Versions =========================================================== Vendor | Use | Version | Dist | Status | Identifier ----------------------------------------------------------- AdoptOpenJDK | | 14.0.0.j9 | adpt | 14.0.0.j9-adpt | | 14.0.0.hs | adpt | 14.0.0.hs-adpt | | 13.0.2.j9 | adpt | Use the Identifier for installation: $ sdk install java 11.0.3.hs-adpt =========================================================== user-iMac:~ user$


Install JDK 13

Next, we will select the version JDK 13 and install it.

user-iMac:~ user$ sdk install java 13.0.2-open Downloading: java 13.0.2-open In progress... ##############################################################100.0% Repackaging Java 13.0.2-open... Done repackaging... Cleaning up residual files... Installing: java 13.0.2-open Done installing! Setting java 13.0.2-open as default. user-iMac:~ user$

Now we can set the default Java version to use.

user-iMac:~ user$ sdk default java 13.0.2-open Default java version set to 13.0.2-open user-iMac:~ user$

Verify Version

Lastly, we can check the version of Java using the following command.

user-iMac:~ user$ java -version openjdk version "13.0.2" 2020-01-14 OpenJDK Runtime Environment (build 13.0.2+8) OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing) user-iMac:~ user$


Here, we have installed Java on MacOS


Congratulations All,you have installed Java JDK successfully on your respective Operating System :)


An Inspirational quote:

"It's not that we use technology, we live technology"


Steps to Subscribe my blog in 15 secs:
1. Enter your mail id in "Subscribe" box.
2. Enter Captcha for verification.
3. A mail will be received with link in your mail id.Just Click on link  and  then Done .Thank you for subscribing :)

Happy Reading.Happy Learning!!! See you in next post  :)

No comments

Note: Only a member of this blog may post a comment.