swanwish / blog

My blog website
0 stars 0 forks source link

Install Java on CentOS 7 #8

Open swanwish opened 7 years ago

swanwish commented 7 years ago

I downloaded the jdk installer jdk-7u60-linux-x64.rpm, but I don't know how to install it, and search the internet, the instruction is like below:

The instructions below are for installing version Java 8 Update 73 (8u73). If you are installing another version, make sure you change the version number appropriately when you type the commands at the terminal. Example: For Java 8u79 replace 8u73 with 8u79. Note that, as in the preceding example, the version number is sometimes preceded with the letter u, and sometimes it is preceded with an underbar, for example, jre1.8.0_73.

Become root by running su and entering the super-user password. Change to the directory in which you want to install. Type:

cd directory_path_name

For example, to install the software in the /usr/java/ directory, Type:

cd /usr/java

Uninstall any earlier installations of the Java packages.

rpm -e package_name

Install the package.

rpm -ivh jre-8u73-linux-x64.rpm 

To upgrade a package:

rpm -Uvh jre-8u73-linux-x64.rpm 

Delete the .rpm file if you want to save disk space. Exit the root shell. No need to reboot.

swanwish commented 7 years ago

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
swanwish commented 5 years ago

Install jre 1.8

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jre-8u191-linux-x64.rpm"