Linux 更换jdk版本,tomcat 运行还是用的老版本的解决办法

6 篇文章 0 订阅
2 篇文章 0 订阅

今天把Linux系统上的jdk1.7升级为jdk1.8,升级完成之后,环境变量也配置成功。但是tomcat启动和停止的时候,使用的还是jdk1.7 的版本。在网上查了一下方法,记录一下。

首先,安装JDK

  • 拷贝安装包:
[root@cuierdan java]# ll
-rw-r--r--  1 root root 181435897 Jun  7 15:38 jdk-8u102-linux-x64.tar.gz
  • 解压文件:
[root@cuierdan src]# tar -zxvf jdk-8u102-linux-x64.tar.gz -C /usr/java/
  • 查看解压文件:
[root@cuierdan java]# ll
drwxr-xr-x  8 uucp  143      4096 Jun 23  2016 jdk1.8.0_102
-rw-r--r--  1 root root 181435897 Jun  7 15:38 jdk-8u102-linux-x64.tar.gz

配置环境变量

进入配置文件

[root@cuierdan java]# vim /etc/profile

在文件的后面追加以下配置,或者修改配置文件

export JAVA_HOME=/usr/java/jdk1.8.0_102
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
  • 使环境变量生效
[root@cuierdan jdk1.8.0_102]# source /etc/profile
  • 检测环境变量是否配置成功
[root@cuierdan java]# java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
[root@cuierdan java]# javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -parameters                Generate metadata for reflection on method parameters
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -h <directory>             Specify where to place generated native header files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -profile <profile>         Check that API used is available in the specified profile
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

以上部分就成功的将JDK安装完成及环境变量配置成功。

当tomcat 启动或停止时,使用的还是老版本的jdk,解决方案如下:

首先进入tomcat 配置文件:

[root@cuierdan bin]# vim /usr/local/tomcat/bin/setclasspath.sh 

在配置文件中加入下面的配置:

export JAVA_HOME=/usr/java/jdk1.8.0_102
export JRE_HOME=/usr/java/jdk1.8.0_102/jre

现在开启或停用tomcat 时,使用的就是新的jdk1.8了,如下:

[root@cuierdan bin]# service tomcat stop
Shutting down tomcat: Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_102/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
tomcat stop ok.
[root@cuierdan bin]# service tomcat start
Starting tomcat: Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_102/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
tomcat start ok.

记录完毕。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值