Skip to content

Instantly share code, notes, and snippets.

@mohanpedala
Last active July 22, 2017 22:37
Show Gist options
  • Save mohanpedala/fdb1e67afd8b0e87db520c0ad37f79f2 to your computer and use it in GitHub Desktop.
Save mohanpedala/fdb1e67afd8b0e87db520c0ad37f79f2 to your computer and use it in GitHub Desktop.
Oracle JDK8 installation on RHEL 7

Download Oracle JDK 8

  1. Visit Oracle JDK download page, look for RPM version.
  2. Copy the rpm link and wget it
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" Download link.rpm 

Note: Install wget if missing

sudo yum install wget -y
  1. Install oracle jdk8
sudo yum localinstall jdk8 downloaded package name.rpm
  1. Verfication
java -version
  1. Delete the rpm file
rm ~/jdk8 downloaded package name.rpm 
  1. Set Environment variables This is good practice to set the JAVA_HOME environment variable. 6.1 Edit the .bash_profile, and append the export JAVA_HOME at the end of the file, for example :

.bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

export JAVA_HOME=/usr/java/jdk1.8.0_102/
export JRE_HOME=/usr/java/jdk1.8.0_102/jre

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export PATH
6.2 Test the $JAVA_HOME and $PATH

$ source .bash_profile

$ echo $JRE_HOME
/usr/java/jdk1.8.0_102/jre

$ echo $JAVA_HOME
/usr/java/jdk1.8.0_102/

$ echo $PATH
/...:/usr/local/bin:/usr/X11R6/bin:/home/mkyong/bin:/usr/java/jdk1.8.0_102//bin

  1. If the RHEL has multiple JDK installed, you can use the alternatives command to set the default java

$ sudo alternatives --config java
[sudo] password for mkyong:

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
*+ 2           /usr/java/jdk1.8.0_102/jre/bin/java

Enter to keep the current selection[+], or type selection number:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment