`

tomcat 一闪而过,Neither the JAVA_HOME or the JRE_HOME environmental variable is defi

阅读更多
先看Tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat。只要在setclasspath.bat的开头声明环境变量,如我的就是:

先讲一个Tomcat的问题。很多人兴冲冲的下载了一个Tomcat,跑到bin看到一个startup.bat就去执行,结果提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program。好,再去下载个最新版本的JDK,Install完成之后却还是提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program。搞得对Tomcat的学习热情冷了一半。


原因是后来较新版本的JDK(例如我使用的JDK1.6)安装完不会自动登记环境变量JAVA_HOME,JRE_HOME。像我在单位的环境,我的用户是受限制的(PowerUser),不方便设环境变量,于是我就找到了另外一个方法。


先看Tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat。只要在setclasspath.bat的开头声明环境变量,如我的就是:

只要在setclasspath.bat的开头声明环境变量,如我的就是:

rem ---------------------------------------------------------------------------
rem Set CLASSPATH and Java options
rem
rem $Id: setclasspath.bat 505241 2007-02-09 10:22:58Z jfclere $
rem ---------------------------------------------------------------------------

set JAVA_HOME=C:\jdk6.0
set JRE_HOME=C:\jre1.6.0

rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo At least one of these environment variable is needed to run this program
goto exit
......

这样在每次运行startup.bat时就注册了JAVA_HOME,JRE_HOME。控制台窗口关闭后,这两个变量也将消失,不会再占用内存。运行一下,最终提示“信息:Server startup in xxxxx ms”就大功告成了。



分享到:
评论

相关推荐

    Kubuntu下安装配置Tomcat

    错误1:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program 错误2: Neither the JAVA_HOME nor the JRE_HOME ...

    Neither_Snow_Nor_Rain_Nor_MITM_._._._An_Empirical_Analysis_of

    Neither_Snow_Nor_Rain_Nor_MITM_ 红蓝对抗 安全对抗 业务安全 安全威胁 金融安全

    Java邮件开发Fundamentals of the JavaMail API

    addition, you will need a development environment such as the JDK 1.1.6+ or the Java 2 Platform, Standard Edition (J2SE) 1.2.x or 1.3.x. A general familiarity with object-oriented programming ...

    Java+structs快速学习指南

    notEmpty Evaluate the nested body content of this tag if the requested variable is neither null nor an empty string. notEqual Evaluate the nested body content of this tag if the requested variable is ...

    2009 达内Unix学习笔记

    将一个命令的输出内容写入到一个文件里面。如果该文件存在, 就将该文件的内容覆盖; 如果不存在就先创建该文件, 然后再写入内容。 输出重定向,意思就是说,将原来屏幕输出变为文件输出,即将内容输到文件中。 ...

    Addison.Wesley.The.Java.Programming.Language.4th.Edition.Aug.2005.chm

    It also covers most of the classes in the main packages (java.lang, java.util, java.io) as implemented in the J2SE™ Development Kit 5.0 (more commonly known as JDK 5.0, or in the older nomenclature ...

    SSD7 选择题。Multiple-Choice

    (b) the name of the table, the names of the table's attributes, the data types of the table's attributes, the formats of the table's attributes, and the maximum number of rows that the table can have...

    unrxlib_275_u_1_0_13

    results from the correct or incorrect usage of this software even if the author(s) has been informed of the possibilities of such damage. Neither the author(s) nor anybody connected to this ...

    Tomcat9安装windows服务的详细教程

    1.准备工作 1.1 下载有service.bat的tomcat压缩包,下载地址 https://tomcat.apache.org 1.2 解压缩到自定义的指定目录 ...4.添加tomcat到windows服务方式一 打开cmd(如果权限不够请已管理员身份运行)进入

    Java Data Science Made Easy

    Java: Data Science Made Easy Copyright © 2017 Packt Publishing All rights reserved. No part of this course may be reproduced, stored in a retrieval system, or transmitted in any form or by any means,...

    JAVA反编译软件

    This is README file for Java Decompiler. JD home page: http://java.decompiler.free.fr Copyright 2008 Emmanuel Dupuy. 1. Installation. No installation and no setup are required. 2. Description JD-GUI...

    Springer Mathematical Aspects of Computer and Information Sciences

    Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The ...

    netWindows_0.3.0_pre2

    Neither the names of Licensor, nor the names ofany contributors to the Original Work, nor any of their trademarks or servicemarks, may be used to endorse or promote products derived from this ...

    The irrationals: a story of the numbers you can't count on

    That definition seems so simple: they are numbers that cannot be expressed as a ratio of two integers, or that have decimal expansions that are neither infinite nor recurring. But, as The Irrationals...

    The Princeton Companion To Mathematics

    containing one or more variables, the same in the two propositions, and neither p nor q contains any constants except logical constants. And logical constants are all notions definable in terms of the...

    一款好用的Java反编译器

    JD home page: http://java.decompiler.free.fr Copyright 2008 Emmanuel Dupuy. 1. Installation. No installation and no setup are required. 2. Description JD-GUI is a standalone graphical utility that ...

    OOP_EN_V3_0.pdf

    The information provided in this documentation contains general descriptions and/or technical characteristics of the performance of the products contained herein. This documentation is not intended as...

    计算机网络第六版答案

    23. The five layers in the Internet protocol stack are – from top to bottom – the application layer, the transport layer, the network layer, the link layer, and the physical layer. The principal ...

    delphixe10 RxLib_For_RX10插件

    results from the correct or incorrect usage of this software even if the author(s) has been informed of the possibilities of such damage. Neither the author(s) nor anybody connected to this ...

    微软内部资料-SQL性能优化5

    The order of pages in the page chain, and the order of rows on the data pages, is the order of the index key or keys. Deciding which key to cluster on is an important performance consideration. When ...

Global site tag (gtag.js) - Google Analytics