大专生JAVA这条路---tomcat与web程序结构
2010-03-23 21:01
399 查看
今天自学了 X老师的课堂录制视频,虽然以前也曾用TOMCAT开发的软件,特别刚开始从事JAVA Web 环境变量的配置都只知道要配置!以前都是跟着课本上的步骤配置TOMCAT的环境变量,而也没有问过为什么要这样配置。因为我们搞JAVA的初级人员对.bat中的命令不通!今天在老师的讲解下,对.bat执行也有了初步的理解,对配置也就豁然开朗了@!因此,我也不得不承认,这儿的培训的确比当今大多数的培训机构都牛!但这并不能说明什么,因为在实际的开发的,或者根本不需要。
1.TOMCAT 为什么要配置环境变量
对tomcat 安装目录下 bin/startup.bat 批处理文件代码的理解:
每一条批处理语句相当于一条DOS下的命令
@echo off --------->DOS在运行批处理时,会依次执行批处理中的每条命令,并且 会在显示器上显示,如果你不想让它们显示,可以加一个“echo off”,当然,“echo off”也是命令,它本身也会显示,如果连这条也不显示,就在前面加个“@”。
┝------------------------->rem 表示后面的是注释
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.
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 908749 2010-02-10 23:26:42Z markt $
rem ---------------------------------------------------------------------------
rem Guess CATALINA_HOME if not defined
设置CURRENT_DIR 为当前目录
set "CURRENT_DIR=%cd%"
如果CATALINA_HOME为 空去执行 gotHome
if not "%CATALINA_HOME%" == "" goto gotHome
设置环境变量为变量CURRENT_DIR的值
set "CATALINA_HOME=%CURRENT_DIR%"
如果"%CATALINA_HOME%/bin/catalina.bat 文件存在 goto okHome
if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHome
回到上一级目录
cd ..
设置环境变量为变量为当前路径
set "CATALINA_HOME=%cd%"
相当于DOS下的cd 命令
cd "%CURRENT_DIR%"
gotHome 程序块
:gotHome
如果下面的批处理文件存在 goto okHome
if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHome
输出以下的消息
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
goto end
之后的语句意思都差不多,不在备注
:okHome
set "EXECUTABLE=%CATALINA_HOME%/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
从以上可知,会调用/bin/catalina.bat批处理问题,而在catalina 批处理文件中又会执行setclasspath.bat 批处理文件。其中引用到环境变量:"%CATALINA_HOME%
"%JAVA_HOME%",如果CATALINA_HOME未设置时,将bin/startup.bat 以快捷键的方式移动到其它目录试图启动tomcat 将会失败。而JAVA_HOME则是寻找到JAVA类路径的途径。
1.TOMCAT 为什么要配置环境变量
对tomcat 安装目录下 bin/startup.bat 批处理文件代码的理解:
每一条批处理语句相当于一条DOS下的命令
@echo off --------->DOS在运行批处理时,会依次执行批处理中的每条命令,并且 会在显示器上显示,如果你不想让它们显示,可以加一个“echo off”,当然,“echo off”也是命令,它本身也会显示,如果连这条也不显示,就在前面加个“@”。
┝------------------------->rem 表示后面的是注释
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.
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 908749 2010-02-10 23:26:42Z markt $
rem ---------------------------------------------------------------------------
rem Guess CATALINA_HOME if not defined
设置CURRENT_DIR 为当前目录
set "CURRENT_DIR=%cd%"
如果CATALINA_HOME为 空去执行 gotHome
if not "%CATALINA_HOME%" == "" goto gotHome
设置环境变量为变量CURRENT_DIR的值
set "CATALINA_HOME=%CURRENT_DIR%"
如果"%CATALINA_HOME%/bin/catalina.bat 文件存在 goto okHome
if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHome
回到上一级目录
cd ..
设置环境变量为变量为当前路径
set "CATALINA_HOME=%cd%"
相当于DOS下的cd 命令
cd "%CURRENT_DIR%"
gotHome 程序块
:gotHome
如果下面的批处理文件存在 goto okHome
if exist "%CATALINA_HOME%/bin/catalina.bat" goto okHome
输出以下的消息
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
goto end
之后的语句意思都差不多,不在备注
:okHome
set "EXECUTABLE=%CATALINA_HOME%/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
从以上可知,会调用/bin/catalina.bat批处理问题,而在catalina 批处理文件中又会执行setclasspath.bat 批处理文件。其中引用到环境变量:"%CATALINA_HOME%
"%JAVA_HOME%",如果CATALINA_HOME未设置时,将bin/startup.bat 以快捷键的方式移动到其它目录试图启动tomcat 将会失败。而JAVA_HOME则是寻找到JAVA类路径的途径。
相关文章推荐
- java程序员第八课 tomcat与web程序结构与Http协议
- tomcat+java的web程序持续占cpu高问题调试【转】
- 在 Tomcat 中部署 Java Web 程序 ( jar cvf *.war */. ) war 包
- Tomcat与web程序结构与Http协议
- Tomcat&Web程序结构&Http协议(一)
- Java Web之Tomcat目录结构和Web应用
- 关于Java web程序中出现Server Tomcat v8.0 Server at localhost failed to start.的问题解决办法
- TOMCAT的目录结构 1++ Tomact的一些小配置2++Java Web开发: Tomcat中部署项目的三种方法
- JAVA web 程序设计的目录结构解读和新建一个程序、部署和运行
- Windows平台下tomcat+java的Web程序占用CPU的性能调试
- java web 简析--二,TOMCAT结构及运行过程解析
- linux tomcat部署含有matlab画图打包的java web程序
- day01-tomcat与web程序结构与Http协议
- Java Web 程序的目录结构
- tomcat与web程序结构与Http协议与HttpUrlConnection(带答案)
- HzhJava框架搭建二:添加tomcat和spring运行一个简单web程序
- tomcat+java的web程序持续占cpu问题调试
- 黑马程序员Android第55期——tomcat与web程序结构与Http协议
- tomcat+java的web程序持续占cpu问题调试
- 在tomcat中用jndi配置数据源启动java web程序