Thursday, 22 June 2017

Instaling Java in linux




1. Completely remove the OpenJDK/JRE from your system and create a directory to hold your Oracle Java JRE binaries

Type/Copy/Paste: sudo apt-get purge openjdk-\*
 This command will completely remove OpenJDK/JRE from your system

Type/Copy/Paste: sudo mkdir -p /usr/local/java
 This command will create a directory to hold your Oracle Java JDK and JRE binaries.

2. Download the jre/jdk

3. Copy the Oracle Java binaries into the /usr/local/java directory

32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:

Type/Copy/Paste: cd /home/"your_user_name"/Downloads
Type/Copy/Paste: sudo cp -r jre-8u73-linux-i586.tar.gz /usr/local/java
Type/Copy/Paste: cd /usr/local/java
 
64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:

Type/Copy/Paste: cd /home/"your_user_name"/Downloads
Type/Copy/Paste: sudo cp -r jre-8u73-linux-x64.tar.gz /usr/local/java
Type/Copy/Paste: cd /usr/local/java

4. Run the following commands on the downloaded Oracle Java tar.gz files. Make sure to do this as root in order to make them executable for all users on your system. To open a root terminal type sudo -s you will be prompted for your logon password.

32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:
Type/Copy/Paste: sudo chmod a+x jre-8u73-linux-i586.tar.gz
 
64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:
Type/Copy/Paste: sudo chmod a+x jre-8u73-linux-x64.tar.gz

5. Unpack the compressed Java binaries, in the directory /usr/local/java

32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:
Type/Copy/Paste: sudo tar xvzf jre-8u73-linux-i586.tar.gz
64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:
Type/Copy/Paste: sudo tar xvzf jre-8u73-linux-x64.tar.gz

6. Double-check your directories. At this point, you should have an uncompressed binary directory in /usr/local/java for the Java JDK/JRE listed as:

Type/Copy/Paste: ls -a
jre1.8.0_73

7. Edit the system PATH file /etc/profile and add the following system variables to your system path. Use nano, gedit or any other text editor, as root, open up /etc/profile.

Type/Copy/Paste: sudo gedit /etc/profile
or
Type/Copy/Paste: sudo nano /etc/profile

8. Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file:

Type/Copy/Paste:

JAVA_HOME=/usr/local/java/jre1.8.0_73
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

9. Save

10. Inform your Ubuntu Linux system where your Oracle Java JRE is located. This will tell the system that the new Oracle Java version is available for use.

Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.8.0_73/bin/java" 1
 this command notifies the system that Oracle Java JRE is available for use

Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.8.0_73/bin/javaws" 1
this command notifies the system that Oracle Java Web start is available for use

11. Inform your Ubuntu Linux system that Oracle Java JRE must be the default Java.

Type/Copy/Paste: sudo update-alternatives --set java /usr/local/java/jre1.8.0_73/bin/java
This command will set the Java runtime environment for the system

Type/Copy/Paste: sudo update-alternatives --set javaws /usr/local/java/jre1.8.0_73/bin/javaws
this command will set Java Web start for the system

12. Reload your system wide PATH /etc/profile by typing the following command:

Type/Copy/Paste: . /etc/profile
Note your system-wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system

13. A successful installation of 32-bit Oracle Java will display:

Type/Copy/Paste: java -version
This command displays the version of Java running on your system

You should receive a message which displays:

java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)

Note:  "jre-8u73-linux-i586.tar.gz" this file name can be different for you so please check the package name before following the instructions.