查看已安装的JDK版本:
java -version
查看已安装的JDK:
rpm -qa | grep jdk
卸载JDK:
rpm -e --nodeps [JDK name1] [JDK name2] [JDK name3]
或者
yum -y remove [JDK name1] [JDK name2] [JDK name3]
查看JAVA相关文件:
rpm -qa | grep java
卸载JAVA相关文件:
rpm -e --nodeps [name1] [name2] [name3]
*下文以安装 jdk1.8.0_162为范例
解压JDK安装包:
tar -zxvf jdk-8u162-linux-x64.tar.gz
创建文件夹/usr/local/jdk/jdk1.8.0_162:
mkdir /usr/local/jdk/jdk1.8.0_162
移动解压后文件至/usr/local/jdk/jdk1.8.0_162:
mv jdk1.8.0_162 /usr/local/jdk/jdk1.8.0_162
配置:
sed -i '$a ulimit -n 65535' /etc/profile
sed -i '$a export JAVA_HOME=/usr/local/jdk/jdk1.8.0_162' /etc/profile
sed -i '$a export JRE_HOME=$JAVA_HOME/jre' /etc/profile
sed -i '$a export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH' /etc/profile
sed -i '$a export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' /etc/profile
source /etc/profile
检测安装是否成功:
java -version
javac
查看JAVA_HOME
echo $JAVA_HOME