0% found this document useful (0 votes)
62 views

JAVA JDK Installation For Linux/MAC Users

This document provides instructions for installing the Java JDK on Linux and macOS systems. It outlines 3 steps: 1) Downloading the correct JDK file for the user's system from Oracle's website, 2) Extracting and moving the file to /usr/lib/jvm and configuring alternatives, 3) Creating an environment variables file and sourcing it to set paths and variables like JAVA_HOME. For macOS, installation only requires double clicking the downloaded DMG file.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

JAVA JDK Installation For Linux/MAC Users

This document provides instructions for installing the Java JDK on Linux and macOS systems. It outlines 3 steps: 1) Downloading the correct JDK file for the user's system from Oracle's website, 2) Extracting and moving the file to /usr/lib/jvm and configuring alternatives, 3) Creating an environment variables file and sourcing it to set paths and variables like JAVA_HOME. For macOS, installation only requires double clicking the downloaded DMG file.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

JAVA JDK Installation for Linux/MAC Users.

Note: Ubuntu 14.04 LTS and later versions are recommended.

STEP 1: Download the latest Java JDK


For that you have to go the official oracle page mentioned below.

http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-
138363.html

Click on “DOWNLOAD” in the JAVA tab as shown in the figure below

Accept the agreement and download according to your architecture 32 or


64 bit.

64 bit linux users download: JDK-8u121-linux-x64.tar.gz

32 bit linux users download: JDK-8u121-linux-i586.tar.gz

MAC users download: JDK-8u121-macosx-x64.dmg

www.fastbitlab.com Page 1
STEP2: Installation for Linux users
1) Extract the tar file which you just downloaded.

www.fastbitlab.com Page 2
It is highly recommended that this JDK folder must be in the location
/usr/lib/jvm.

So, let’s move it !

Open your terminal and execute the below command.

Note: Please use the appropriate path where you extracted the tar file. In my
case it is under the path “/home/kiran/java”.

sudo mkdir -p /usr/lib/jvm/java_jdk_8

sudo mv /home/kiran/java/jdk1.8.0_121/ /usr/lib/jvm/java_jdk_8/

Great! Now we moved the JDK folder in to /usr/lib/jvm/java_jdk_8

2)

Now, in your machine java might have already installed or not installed, So
running the below command will show you the java version installed in your
machine, if no java is installed , then it will return “no alternatives “

Just try the below command on your terminal software.

sudo update-alternatives --query java

sudo update-alternatives --query javac

Now, let’s add the new alternative

sudo update-alternatives --install /usr/bin/java java


/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/jre/bin/java 2000

sudo update-alternatives --install /usr/bin/javac javac


/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/bin/javac 2000

*2000 is the priority and feel free to pick a different number

Now you should see the new JDK listed and you can switch between the
alternatives with this command:

sudo update-alternatives --config java

sudo update-alternatives --config javac

www.fastbitlab.com Page 3
Great! Now we have successfully installed the new version of the JAVA JDK.
But, it’s not sufficient. Now we have to change various environment variables.

3) Changing environment variables.

For this you have to create one .sh file in the location
/etc/profile.d/myjavajdk.sh

sudo vi /etc/profile.d/myjavajdk.sh

Put the below contents in to that file and save.

export J2SDKDIR=/usr/lib/jvm/java_jdk_8/jdk1.8.0_121

export J2REDIR=/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/jre

export
PATH=$PATH:/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/bin:/usr/lib/jvm/java_jdk_8
/jdk1.8.0_121/db/bin:/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/jre/bin

export JAVA_HOME=/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/

export DERBY_HOME=/usr/lib/jvm/java_jdk_8/jdk1.8.0_121/db

The same file is available for download in the resource section. So you can
just download and put it under /etc/profile.d .

JAVA_HOME points to the directory of newly installed java JDK. Eclipse


depends on the value of JAVA_HOME.

Great, now execute the below command to apply all these environmental
variable settings.

source /etc/profile.d/myjavajdk.sh.

STEP 2: installation for MAC users.


For MAC users it is super simple, after downloading the jdk-8u121-macosx-
x64.dmg file, just double click on it and complete the installation steps. That’s
it. After installation confirm the java version by typing the below command

www.fastbitlab.com Page 4
java -version

This must show the version of the latest java JDK installation you just did.

www.fastbitlab.com Page 5

You might also like