码迷,mamicode.com
首页 > 其他好文 > 详细

配置JDK和Tomcat环境变量

时间:2015-04-17 13:04:27      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

原文:http://blog.csdn.net/lijiazhi1987/article/details/2742181

1.安装JDK

安装好JDK后,再配置JDK的环境变量:
在“我的电脑”上点右键—>“属性”—>“高级”—> “环境变量(N)”。

新建系统变量JAVA_HOME:C:/Program Files/Java/jdk1.5.0_06;

新建系统变量CLASSPATH:.;%JAVA_HOME%/lib;(注意:点号表示当前目录,不能省略)

在系统变量Path的值的前面加入以下内容:%JAVA_HOME%/bin;(注意:这里的分号不能省略)

到这里,JDK安装完毕。


2.安装Tomcat

安装好Tomcat后,再配置Tomcat的环境变量:
在“我的电脑”上点右键—>“属性”—>“高级”—> “环境变量(N)”。

新建系统变量CATALINA_HOME:D:/jakarta-tomcat-5.0.30

在系统变量CLASSPATH的值的后面加入:%CATALINA_HOME%/common/lib;

在系统变量Path的值中"%JAVA_HOME%/bin;"的后面加入以下内容:%CATALINA_HOME%/bin;

到这里,Tomcat安装完毕。


配置好以上环境变量之后,各系统变量的值如下:
JAVA_HOME:C:/Program Files/Java/jdk1.5.0_06 
CATALINA_HOME:D:/jakarta-tomcat-5.0.30 
CLASSPATH:.;%JAVA_HOME%/lib;%CATALINA_HOME%/common/lib; 
Path:%JAVA_HOME%/bin;%CATALINA_HOME%/bin;%SystemRoot%/system32;%SystemRoot%;%

SystemRoot%/System32/Wbem


------------------------------------------------------------------------
测试JDK和Tomcat

打开cmd进行测试JDK是否配置成功: 

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:/Documents and Settings/Administrator>java  
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

where options include:
    -client       to select the "client" VM
    -server       to select the "server" VM
    -hotspot      is a synonym for the "client" VM  [deprecated]
                  The default VM is client.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose[:class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image

技术分享

C:/Documents and Settings/Administrator>javac --输入javac显示下面的内容就是配置成功
用法:javac <选项> <源文件>
其中,可能的选项包括:
  -g                         生成所有调试信息
  -g:none                    不生成任何调试信息
  -g:{lines,vars,source}     只生成某些调试信息
  -nowarn                    不生成任何警告
  -verbose                   输出有关编译器正在执行的操作的消息
  -deprecation               输出使用已过时的 API 的源位置
  -classpath <路径>            指定查找用户类文件和注释处理程序的位置
  -cp <路径>                   指定查找用户类文件和注释处理程序的位置
  -sourcepath <路径>           指定查找输入源文件的位置
  -bootclasspath <路径>        覆盖引导类文件的位置
  -extdirs <目录>              覆盖安装的扩展目录的位置
  -endorseddirs <目录>         覆盖签名的标准路径的位置
  -proc:{none,only}          控制是否执行注释处理和/或编译。
  -processor <class1>[,<class2>,<class3>...]要运行的注释处理程序的名称;绕过默认
的搜索进程
  -processorpath <路径>        指定查找注释处理程序的位置
  -d <目录>                    指定存放生成的类文件的位置
  -s <目录>                    指定存放生成的源文件的位置
  -implicit:{none,class}     指定是否为隐式引用文件生成类文件
  -encoding <编码>             指定源文件使用的字符编码
  -source <版本>               提供与指定版本的源兼容性
  -target <版本>               生成特定 VM 版本的类文件
  -version                   版本信息
  -help                      输出标准选项的提要
  -Akey[=value]              传递给注释处理程序的选项
  -X                         输出非标准选项的提要
  -J<标志>                     直接将 <标志> 传递给运行时系统

技术分享
C:/Documents and Settings/Administrator>

 

测试Tomcat是否配置成功:

进入Tomcat目录下的bin里面
双击startup.bat
如果显示下列信息就配置成功

2008-7-30 21:27:34 org.apache.coyote.http11.Http11Protocol init
严重: Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind:8080
        at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoi
nt.java:297)
        at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:142)

        at org.apache.catalina.connector.Connector.initialize(Connector.java:918
)
        at org.apache.catalina.core.StandardService.initialize(StandardService.j
ava:580)
        at org.apache.catalina.core.StandardServer.initialize(StandardServer.jav
a:764)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:490)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:509)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:243)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:408)
2008-7-30 21:27:34 org.apache.catalina.startup.Catalina load
严重: Catalina.start
LifecycleException:  Protocol handler initialization failed: java.net.BindExcept
ion: Address already in use: JVM_Bind:8080
        at org.apache.catalina.connector.Connector.initialize(Connector.java:920
)
        at org.apache.catalina.core.StandardService.initialize(StandardService.j
ava:580)
        at org.apache.catalina.core.StandardServer.initialize(StandardServer.jav
a:764)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:490)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:509)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:243)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:408)
2008-7-30 21:27:34 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 625 ms
2008-7-30 21:27:34 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2008-7-30 21:27:34 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.7
2008-7-30 21:27:34 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2008-7-30 21:27:34 org.apache.catalina.core.ApplicationContext log
信息: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.
webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule:
 Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.bal
ancer.rules.RequestParameterRule: Target param name: paramName / Target param va
lue: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balanc
er.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
log4j:WARN No appenders could be found for logger (org.apache.catalina.session.M
anagerBase).
log4j:WARN Please initialize the log4j system properly.
2008-7-30 21:27:35 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2008-7-30 21:27:35 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
log4j:WARN No appenders could be found for logger (org.apache.catalina.session.M
anagerBase).
log4j:WARN Please initialize the log4j system properly.
2008-7-30 21:27:37 org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config=‘org.apache.struts.util.LocalStrings‘, returnNull=tru
e
2008-7-30 21:27:37 org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config=‘org.apache.struts.action.ActionResources‘, returnNul
l=true
2008-7-30 21:27:38 org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config=‘com.yourcompany.struts.ApplicationResources‘, return
Null=true
2008-7-30 21:27:39 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2008-7-30 21:27:39 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
log4j:WARN No appenders could be found for logger (org.apache.catalina.session.M
anagerBase).
log4j:WARN Please initialize the log4j system properly.
2008-7-30 21:27:43 org.apache.coyote.http11.Http11Protocol start
严重: Error starting endpoint
java.net.BindException: Address already in use: JVM_Bind:8080
        at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoi
nt.java:297)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.startEndpoint(PoolTcpEndpo
int.java:312)
        at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:181
)
        at org.apache.catalina.connector.Connector.start(Connector.java:990)
        at org.apache.catalina.core.StandardService.start(StandardService.java:4
59)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:683
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
2008-7-30 21:27:43 org.apache.catalina.startup.Catalina start
严重: Catalina.start:
LifecycleException:  Protocol handler start failed: java.net.BindException: Addr
ess already in use: JVM_Bind:8080
        at org.apache.catalina.connector.Connector.start(Connector.java:992)
        at org.apache.catalina.core.StandardService.start(StandardService.java:4
59)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:683
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
2008-7-30 21:27:43 org.apache.catalina.startup.Catalina start
信息: Server startup in 9188 ms

技术分享

配置JDK和Tomcat环境变量

标签:

原文地址:http://www.cnblogs.com/jexwn/p/4434247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!