Here’s a BASH script I wrote which downloads and installs the Java JDK RPM. Tested on CentOS 6.x. If you are looking to install on Ubuntu (or Mint) go here.

It also downloads the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files which are required for some applications.

You must replace the version variables in order to download the latest version. Here are the instructions for finding these.

  1. To find them go here and under the Java category go to Java SE.
  2. Click the big Java Download near the top.
  3. Click Accept License Agreement to view the links for the downloads.
  4. Find the Linux x64 if you are on a 64 bit OS or Linux i586 if you are on 32 bit. If you don’t know then you’re probably on 64 bit.
  5. Right click on the link in the right side column and go to Copy Link Location or Copy link address, etc.
  6. Now you can use this link you’ve copied to find the version numbers required. At the moment CURRENT and MINOR are not specified anywhere in the URL. Here is an image illustrating the MAJOR, REV and BUILD variables which you can update. In the future I am planning to write some regex to parse these out but haven’t
  7. Save the script below into a file and make the file executable:
    chmod +x
  8. Run the script to install / update java:
# Install Java JDK RPM

# Version variables
# md5 hash added to URL 17th Jan 2017

# Compile variables

# Download Java
wget --no-cookies --no-check-certificate --header 'Cookie: oraclelicense=accept-securebackup-cookie' "${URL}" -O "./${RPM}"

# Install Java
yum -y localinstall "./${RPM}"

# Alternatives
alternatives --install /usr/bin/java java ${JPATH}/jre/bin/java 20000
alternatives --install /usr/bin/jar jar ${JPATH}/bin/jar 20000
alternatives --install /usr/bin/javac javac ${JPATH}/bin/javac 20000
alternatives --install /usr/bin/javaws javaws ${JPATH}/jre/bin/javaws 20000
alternatives --set java ${JPATH}/jre/bin/java
alternatives --set javaws ${JPATH}/jre/bin/javaws
alternatives --set javac ${JPATH}/bin/javac
alternatives --set jar ${JPATH}/bin/jar

# Remove download
rm "./${RPM}"

# Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files
# Note: This is only required for some applications.
wget --no-cookies --no-check-certificate --header 'Cookie: oraclelicense=accept-securebackup-cookie' "${POLICY_URL}" -O "./${POLICY_FILE}"
unzip -u "./${POLICY_FILE}"
cp -f ./UnlimitedJCEPolicyJDK${MAJOR}/*.jar ${JPATH}/jre/lib/security/
rm "./${POLICY_FILE}"
rm -rf ./UnlimitedJCEPolicyJDK${MAJOR}/



  • Requires wget to be installed.
  • Requires unzip (for JCE) to be installed.
  • Does not update the JAVA_HOME or PATH environment variables. You can set them to /usr/java/latest which symlinks to the proper Java version.

Please report any issues.