Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Installing Alternative Java Versions on RHEL/CentOS

Submitted by on October 26, 2016 – 2:23 pm

Below is shorthand for installing alternative versions of Java on your RHEL/CentOS system. This may come in useful for the purposes of testing.

# Set version, update, and filename

v="jdk1.8.0_101"
r="8u101-b13"
f="jdk-8u101-linux-x64.tar.gz"

cd /opt
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/${r}/${f}"
tar xzf ${f} && /bin/rm -f ${f}
cd /opt/${v}
alternatives --install /usr/bin/java java /opt/${v}/bin/java 2
alternatives --install /usr/bin/jar jar /opt/${v}/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/${v}/bin/javac 2
alternatives --set jar /opt/${v}/bin/jar
alternatives --set javac /opt/${v}/bin/javac
export JAVA_HOME=/opt/${v}
export JRE_HOME=/opt/${v}/jre
export PATH=$PATH:/opt/${v}/bin:/opt/${v}/jre/bin
cat >> /etc/environment << EOF
JAVA_HOME=/opt/${v}
JRE_HOME=/opt/${v}/jre
PATH=$PATH:/opt/${v}/bin:/opt/${v}/jre/bin
EOF

Interactive step – select default Java version and verify
alternatives --config java
java -version

 

 

Print Friendly, PDF & Email

Leave a Reply