linux的jdk版本更换
作者:互联网
jdk版本更换
1.下载安装包
https://www.oracle.com/java/technologies/downloads/archive/
2.上传安装包到java安装路径
3.解压文件夹
cd /usr/java
tar -zxvf jdk-8u102-linux-x64.tar.gz
4.配置环境变量
vi /etc/profile
#增加或修改以下配置
export JAVA_HOME=/usr/java/jdk1.8.0_281
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5.让配置生效
source /etc/profile
6.测试是否配置成功
[root@localhost java]# java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
tomcat启动或停止依旧使用老版本jdk
- 原因是在tomcat的配置文件里指定了jdk的绝对路径,tomcat就会优先使用自身的配置而非全局变量。
1.查看tomcat/bin/catalina.sh
- 如果有相关配置,修改或去除
cat /home/apache-tomcat-ja/bin/catalina.sh
# -----------------------------------------------------------------------------
JAVA_HOME=/usr/java/jdk1.8.0_281
2.查看tomcat/bin/setclasspash.sh
cat /home/apache-tomcat-ja/bin/setclasspath.sh
JAVA_HOME=/usr/java/jdk1.8.0_281
JRE_HOME=/usr/java/jdk1.8.0_281/jre
- 修改后重启tomcat
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /home/apache-tomcat-ja
Using CATALINA_HOME: /home/apache-tomcat-ja
Using CATALINA_TMPDIR: /home/apache-tomcat-ja/temp
Using JRE_HOME: /usr/java/jdk1.8.0_281/jre
Using CLASSPATH: /home/apache-tomcat-ja/bin/bootstrap.jar:/home/apache-tomcat-ja/bin/tomcat-juli.jar
Tomcat started.
标签:bin,java,jdk,tomcat,home,版本,linux,281,HOME 来源: https://www.cnblogs.com/clearloveblog/p/15845651.html