Last active
May 10, 2017 16:03
-
-
Save mahamuniraviraj/b8144c48044e92d4a4f277ce17854d93 to your computer and use it in GitHub Desktop.
Install Oracle Java 8 on CentOS 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java -version | |
# visit http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html | |
# determine latest jdk version | |
# accept license and select i586/x64 rpm version and click download .ex jdk-8uXXX-linux-x64.rpm where XXX is revision | |
rpm -ivh jdk-8u131-linux-x64.rpm | |
which java | |
cd /usr/java | |
# to verify java | |
ll -lsah | |
# set which java to use when more than one JDK/JRE is installed | |
alternatives --config java | |
alternatives --config javac | |
alternatives --config javaws | |
alternatives --config jar | |
# check alternatives | |
ls -lA /etc/alternatives/ | |
# Set environment variables to set java home and jre home and path | |
# create a file called setJavaEnv.sh under /etc/profile.d/ directory. | |
vi /etc/profile.d/setJavaEnv.sh | |
#press insert and type following lines into script file | |
#!/bin/sh | |
# Sets Java home and add java to path | |
export JAVA_HOME=/usr/java/latest | |
export JDK_HOME=/usr/java/latest | |
export JRE_HOME=/usr/java/latest/jre | |
export PATH=/usr/java/latest/jre:/usr/java/latest:$PATH | |
#press escape and type :wqa to save all and exit | |
# make script exectable | |
chmod +x /etc/profile.d/setJavaEnv.sh | |
# apply changes without restart | |
source /etc/profile.d/setJavaEnv.sh | |
# to test env variables and path is set | |
echo $JAVA_HOME | |
echo $JRE_HOME | |
java -version | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Correct version