Linux uses rpm to reinstall jdk

Linux uses rpm to reinstall jdk

1. Uninstall jdk
#rpm -qa | grep gcj
If there is no content in the output, it means there is no jdk. If there is content in the output, uninstall the searched files. The command is:
#rpm -e --nodeps [file output from the previous operation]
then use
#whereis java
 Delete java related files or folders directly
 
2. Download the jdk you need
Go to oracle official website http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to find the download link
Then use wget to download, because oracle needs accept lincence, wget needs to add some parameters (--no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" )
For example, download the latest jdk8, rpm version
#wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"  http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-linux-x64.rpm
 
3. Install using rpm
Order
#mkdir /usr/local/java
#cd /usr/local/java
Move the download file to /usr/local/java, then install
#rpm -ivh jdk-8u92-linux-x64.rpm
When installing, there will be a waiting output. If no error is reported, the installation is successful.
 
4. Declare environment variables
Configure the environment
#vi /etc/profile (add sudo in front of those without permission)
Add the following at the bottom of the profile
#export JAVA_HOME=/usr/java/jdk1.8.0_92
#export PATH= $PATH: $JAVA_HOME/bin
#export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
If it already exists, modify it to the new installation path.
 
After adding, save and exit, execute the following command to make the configuration take effect 
#source /etc/profile
 
5. Check the jdk version
#java -version
Reprinted from: http://www.cnblogs.com/liusxg/p/5630066.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326252674&siteId=291194637