-
Notifications
You must be signed in to change notification settings - Fork 0
Installing Java
If your version is different, replace all instances of jdk1.8.0_91 with your version
-
Go into the
/opt/directory and use wget to download JDK for Linux x64, replace the link with a link to your jdk version if needed. If wget is not yet installed usesudo yum install wget.wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz" -
Extract the archived content using
tar -vxzf jdk-8u91-linux-x64.tar.gz -
Install Java with Alternatives by first going into the
/opt/jdk1.8.0_91/directory, then do the following:sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_91/bin/java 2 sudo alternatives --config java
When it outputs: ``` There is 1 program that provides 'java'. Selection Command *+ 1 /opt/jdk1.8.0_45/bin/java
Enter to keep the current selection[+], or type selection number:
```
enter 1
- Set up javac and jar command paths using alternatives,
sudo alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_91/bin/jar 2 sudo alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_91/bin/javac 2 sudo alternatives --set jar /opt/jdk1.8.0_91/bin/jar sudo alternatives --set javac /opt/jdk1.8.0_91/bin/javac
then check the java version installed with java -version and make sure you get this output:
java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
-
Configure the environment variables
export JAVA_HOME=/opt/jdk1.8.0_91 export JRE_HOME=/opt/jdk1.8.0_91/jre export PATH=$PATH:/opt/jdk1.8.0_91/bin:/opt/jdk1.8.0_91/jre/bin -
Since the above command only works for this session only, you will need to be added to all system users
- for the Bourne Shell, create a new file called
/etc/profile.d/java.shand put the following script in it
if ! echo ${PATH} | grep -q /opt/jdk1.8.0_91/bin ; then export PATH=/opt/jdk1.8.0_91/bin:${PATH} fi if ! echo ${PATH} | grep -q /opt/jdk1.8.0_91/jre/bin ; then export PATH=/opt/jdk1.8.0_91/jre/bin:${PATH} fi export JAVA_HOME=/opt/jdk1.8.0_91 export JRE_HOME=/opt/jdk1.8.0_91/jre export CLASSPATH=.:/opt/jdk1.8.0_91/lib/tools.jar:/opt/jdk1.8.0_91/jre/lib/rt.jar- For the C shell, create new file called
/etc/profile.d/java.cshand put the following script in it
if ( "${path}" !~ */opt/jdk1.8.0_91/bin* ) then set path = ( /opt/jdk1.8.0_91/bin $path ) endif if ( "${path}" !~ */opt/jdk1.8.0_91/jre/bin* ) then set path = ( /opt/jdk1.8.0_91/jre/bin $path ) endif setenv JAVA_HOME /opt/jdk1.8.0_91 setenv JRE_HOME /opt/jdk1.8.0_91/jre setenv CLASSPATH .:/opt/jdk1.8.0_91/lib/tools.jar:/opt/jdk1.8.0_91/jre/lib/rt.jar - for the Bourne Shell, create a new file called
-
Make sure the owner and ACL for the profile files by executing the following:
sudo chown root:root /etc/profile.d/java.sh sudo chmod 755 /etc/profile.d/java.sh sudo chown root:root /etc/profile.d/java.csh sudo chmod 755 /etc/profile.d/java.csh
Now you can move on to [installing Wildfly](Installing Wildfly 10.0.0 on Centos 7.1)