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/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz" tar xzf jdk-8u171-linux-x64.tar.gz OR tar -xvzf jdk-8u171-linux-x64.tar.gz
cd /opt/jdk1.8.0_171/alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 2 alternatives --config java There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- * 1 /opt/jdk1.7.0_71/bin/java + 2 /opt/jdk1.8.0_45/bin/java 3 /opt/jdk1.8.0_144/bin/java 4 /opt/jdk1.8.0_171/bin/java Enter to keep the current selection[+], or type selection number:4
Download JDK8u171
[psqa@centos7dev opt]$ sudo 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/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz" [sudo] password for psqa: --2018-06-13 23:59:48-- http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz Resolving download.oracle.com (download.oracle.com)... 23.40.20.195 Connecting to download.oracle.com (download.oracle.com)|23.40.20.195|:80... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz [following] --2018-06-13 23:59:48-- https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz Resolving edelivery.oracle.com (edelivery.oracle.com)... 104.100.61.228, 2600:1406:1a:394::2d3e, 2600:1406:1a:3a1::2d3e Connecting to edelivery.oracle.com (edelivery.oracle.com)|104.100.61.228|:443... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1528952524_ca8b6503b6dac351ed59b401468f0db3 [following] --2018-06-13 23:59:49-- http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1528952524_ca8b6503b6dac351ed59b401468f0db3 Connecting to download.oracle.com (download.oracle.com)|23.40.20.195|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 190890122 (182M) [application/x-gzip] Saving to: ‘jdk-8u171-linux-x64.tar.gz’ 100%[=========================================================================================>] 190,890,122 2.27MB/s in 60s 2018-06-14 00:00:49 (3.02 MB/s) - ‘jdk-8u171-linux-x64.tar.gz’ saved [190890122/190890122]
Other Candidates for Creating Alternatives
- not really sold on using alternatives for Java... prefer to 'hard code' each path to allow for parallel versions to be used simultaneously
- might be good to use for the MAIN java version, & then use absolute paths for programs requiring deprecated java versions
alternatives --install/usr/bin/jar jar /opt/jdk1.8.0_171/bin/jar 2alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_171/bin/javac 2alternatives --set jar /opt/jdk1.8.0_171/bin/jaralternatives --set javac /opt/jdk1.8.0_171/bin/javac
This tutorial helps you to install Java 8 or update Java on your system. Read the instruction carefully before downloading Java from Linux command line. To Install Java 8 in Ubuntu and LinuxMint read This Article.
Step 1 – Download Latest Java Archive
The Oracle team provides Java RPM packages as well as compiled source code. Many times I have tried Java installation using rpm packages but I faced some issues. So I decided to install Java using the compiled source code. Since then I have installed a large number of times Java on CentOS, Redhat based systems without any issues. To download the latest Java SE Development Kit 8 release from its official download page or use following commands to download from the shell.
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/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz" tar xzf jdk-8u171-linux-x64.tar.gz
Step 2 – Install Java 8 with Alternatives
The alternatives command is used for maintained symbolic links. This command used to creates, removes, maintains and displays information about the symbolic links comprising the alternatives system. Let’s use the alternatives command to configure Java on your system. The alternatives command is available in chkconfig package.
cd /opt/jdk1.8.0_171/ alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 2 alternatives --config java There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- * 1 /opt/jdk1.7.0_71/bin/java + 2 /opt/jdk1.8.0_45/bin/java 3 /opt/jdk1.8.0_144/bin/java 4 /opt/jdk1.8.0_171/bin/java Enter to keep the current selection[+], or type selection number:4
At this point JAVA 8 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_171/bin/jar 2alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_171/bin/javac 2alternatives --set jar /opt/jdk1.8.0_171/bin/jaralternatives --set javac /opt/jdk1.8.0_171/bin/javac
Step 3 – Check Installed Java Version
Java and javac binaries are available under PATH environment variable. You can use them from anywhere in your system. Let’s check the installed version of Java runtime environment (JRE) on your system by executing the following command.
java -version java version " 1.8.0_171 " Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
Step 4 – Setup Java Environment Variables
Most of Java based application’s uses environment variables to work. Set the Java environment variables using following commands
Set the JAVA_HOME, JRE_HOME and PATH environment variables.
export JAVA_HOME=/opt/jdk1.8.0_171 export JRE_HOME=/opt/jdk1.8.0_171/jre export PATH=$PATH:/opt/jdk1.8.0_171/bin:/opt/jdk1.8.0_171/jre/bin
Also add the above commands to /etc/bashrc file to auto set environment variables on the system boot.
- Log in to post comments