Skip to content

Instantly share code, notes, and snippets.

@smijar
Last active January 20, 2024 02:40
Show Gist options
  • Save smijar/3926fa4eb9bc95281b3ba5de93d73ef8 to your computer and use it in GitHub Desktop.
Save smijar/3926fa4eb9bc95281b3ba5de93d73ef8 to your computer and use it in GitHub Desktop.
Installing JDK 7 or 8 on centos 7/8
# from https://www.digitalocean.com/community/tutorials/how-to-install-java-on-centos-and-fedora
# JDK 7
#------
# Change to your home directory and download the Oracle Java 7 JDK RPM with these commands:
cd ~
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/7u79-b15/jdk-7u79-linux-x64.rpm"
# Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):
sudo yum localinstall jdk-7u79-linux-x64.rpm
# Now Java should be installed at /usr/java/jdk1.7.0_79/jre/bin/java, and linked from /usr/bin/java.
# JRE 7
#------
# Change to your home directory and download the Oracle Java 7 JRE RPM with these commands:
cd ~
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/7u79-b15/jre-7u79-linux-x64.rpm"
# Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):
sudo yum localinstall jre-7u79-linux-x64.rpm
# Now Java should be installed at /usr/java/jdk1.7.0_79/jre/bin/java, and linked from /usr/bin/java.
# SETTING DEFAULT
sudo alternatives --config java
# SETTING JAVA_HOME
export JAVA_HOME=/usr/java/jdk1.8.0_60/jre
# If you want JAVA_HOME to be set for every user on the system by default, add the previous line to the /etc/environment file. An easy way to append it to the file is to run this command:
sudo sh -c "echo export JAVA_HOME=/usr/java/jdk1.8.0_60/jre >> /etc/environment"
# JDK 8
#------
# JDK
# Change to your home directory and download the Oracle Java 8 JDK RPM with these commands:
cd ~
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/8u60-b27/jdk-8u60-linux-x64.rpm"
# Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):
sudo yum localinstall jdk-8u60-linux-x64.rpm
# Now Java should be installed at /usr/java/jdk1.8.0_60/jre/bin/java, and linked from /usr/bin/java.
# JRE 8
#------
# Change to your home directory and download the Oracle Java 8 JRE RPM with these commands:
cd ~
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/8u60-b27/jre-8u60-linux-x64.rpm"
# Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):
sudo yum localinstall jre-8u60-linux-x64.rpm
# Now Java should be installed at /usr/java/jdk1.8.0_60/jre/bin/java, and linked from /usr/bin/java.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment