1.## window10环境下jdk的安装与配置 (1)从官网下载jdk,地址:jdk1.8.0_101,官网链接地址https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 如下图: (2)具体安装步骤打开后一直点击下一步安装完成即可,我安装的目录是c盘,安装过程略。 (3)下面主要是jdk的环境变量配置 3.1 系统变量——》新建JAVA_HOME变量 变量值是你jdk安装的目录,例如:C:\Program Files\Java\jdk1.8.0_101
3.2 系统变量——》找到path变量,进行编辑添加%JAVA_HOME%\bin和%JAVA_HOME%\jre\bin
3.3 系统变量——》新建CLASSPATH变量,变量值填写.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar注意前面有点分号
3.4检验是否配置成功,win+r输入cmd,输入java -version,如图所示 显示版本信息 则说明安装和配置成功 3.5 分别输入java和javac也会有内容输出
以上配置好后就说明jdk的环境已经安装好了
1.下载Tomcat的压缩包,放在一个没有中文命名的路径下。百度云盘地址:https://pan.baidu.com/s/1SpQ1lmrnBBojezp5ioum-A 提取码:eoo7,或者到tomcat官网进行下载https://tomcat.apache.org/download-70.cgi 解压后如下: 因为安装部署2个,将下载好的安装包复制了一份,分别命名如下: apache-tomcat-78080和apache-tomcat-78081
2.下面主要是配置2个tomcat的环境
2.1 分别创建变量,指向2个tomcat的解压目录,我装在D盘,如: 变量名CATALINA_BASE变量值D:\apache-tomcat-78080;变量名CATALINA_BASE2变量值D:\apache-tomcat-78081;变量名CATALINA_HOME变量值D:\apache-tomcat-78080;变量名CATALINA_HOME变量值D:\apache-tomcat-78081 2.2
找到path变量,添加%CATALINA_HOME%\lib、%CATALINA_HOME%\bin、 %CATALINA_HOME2%\lib、%CATALINA_HOME2%\bin 这样2个tomcat的环境就配置好了。
3.配置好了还不能同时启动,端口号和启动服务都会冲突,导致其中一个tomcat启动失败,需要做如下改动: 8080tomcat的conf目录下的server.xml设置成
8081tomcat的conf目录下的server.xml设置成
8081的tomcat的bin目录下的startup.bat里面的%CATALINA_HOME%全部替换成%CATALINA_HOME2%,shutdown.bat里面的%CATALINA_HOME%也全部替换%CATALINA_HOME2%,8080的tomcat的bin目录下的startup.bat和shutdown.bat不动,文件里面内容的调整可以采用EditPlus工具打开。 startup.bat替换后的内容如下:
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem ---------------------------------------------------------------------------
setlocal
rem Guess CATALINA_HOME2 if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME2%" == "" goto gotHome
set "CATALINA_HOME2=%CURRENT_DIR%"
if exist "%CATALINA_HOME2%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME2=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME2%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME2 environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
set "EXECUTABLE=%CATALINA_HOME2%\bin\catalina.bat"
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
:end
shutdown.bat替换后的内容如下:
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Stop script for the CATALINA Server
rem ---------------------------------------------------------------------------
setlocal
rem Guess CATALINA_HOME2 if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME2%" == "" goto gotHome
set "CATALINA_HOME2=%CURRENT_DIR%"
if exist "%CATALINA_HOME2%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME2=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME2%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME2 environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
set "EXECUTABLE=%CATALINA_HOME2%\bin\catalina.bat"
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs
call "%EXECUTABLE%" stop %CMD_LINE_ARGS%
:end
4.下面就可以启动了
这样就完成本地同时启动2个tomcat了