`
wgldwj
  • 浏览: 1658 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

阅读更多
先看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 ...

    windows下直接点击startup.bat启动tomcat服务.docx

    然而,有时可能会遇到一些问题,比如本文档中提到的情况,即在已经安装并配置好JDK的情况下,Tomcat无法正常启动,并抛出错误提示:“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined”。...

    Linux实战总结

    - 错误示例:“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined” 表明没有设置`JAVA_HOME`或`JRE_HOME`环境变量。 - 解决方法:手动设置`JAVA_HOME`环境变量,并确保路径正确。 ```...

    Tomcat安装图解

    如果遇到找不到`JAVA_HOME`路径的问题,即出现类似“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined”的错误,你需要设置`JAVA_HOME`环境变量。假设你的JDK安装在`/usr/java/jdk1.6.0_16`...

    tomcat启动问题

    echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined echo At least one of these environment variables is needed to run this program goto exit ``` 这段代码检查了`JAVA_HOME`...

    Windows t和linux下无法启动Tomcat解决方案

    在Windows环境中,无法启动Tomcat通常表现为以下错误:“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined”。这个错误意味着系统找不到配置的Java开发工具包(JDK)或Java运行环境(JRE)...

    在LINUX下安装JDK1.6

    如果在启动Tomcat时遇到类似“`Neither the JAVA_HOME nor the JRE_HOME environment variable is defined`”的错误提示,这是因为Tomcat没有找到有效的JDK或JRE环境。解决方法是在启动Tomcat之前设置`JAVA_HOME`...

    Neither_Snow_Nor_Rain_Nor_MITM_._._._An_Empirical_Analysis_of

    在网络安全领域,"Neither_Snow_Nor_Rain_Nor_MITM"这一表述暗示了无论面对何种困难,包括恶劣天气或者中间人攻击(Man-in-the-Middle, MITM),都需要坚决捍卫信息安全。MITM攻击是一种常见的网络威胁,攻击者在...

    tomcat启动startup.bat一闪而过问题的解决方法【亲测有效】

    6. 常见错误信息及解决方案:如果遇到错误提示“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined”,说明Tomcat找不到相应的Java环境变量。此时,需要在setclasspath.bat文件中手动声明...

    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 ...

    Neither...nor的用法小结.doc

    例如:Neither dad nor mum is at home today. 今天父母都不在家。 需要注意的是,当主语不是同一个人或物时,nor 和 neither 可互换,例如:I don't know, nor do I care. 我不知道,也不关心。但是,当主语是同一...

    so nor neither的用法总结PPT学习教案.pptx

    so nor neither的用法总结 So 和 Nor/Neither 是英语语法中两个重要的连接词,分别用于表示肯定和否定关系。本文将对 So 和 Nor/Neither 的用法进行总结,并提供实例来帮助读者更好地理解和掌握它们的使用。 一、...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

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

    That said, this book is neither a comparative analysis nor a "bridge" tutorialno knowledge of C or C++ is assumed. C++ programmers, especially, may be as hindered by what they must unlearn as they ...

    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...

    riki_line_follower_opencv_houghopencv_car_ros巡线Python_pythonros巡

    ROS(Robot Operating System)是一个开源操作系统,用于机器人设备和软件的开发、测试和部署。在这个项目中,"riki_line_follower"是一个基于ROS的小车巡线应用,它利用了OpenCV库进行图像处理,结合Hough变换来...

    wireshark-4.2.0源代码

    Wireshark是一款强大的网络封包分析软件,被誉为网络分析的标准工具。它的主要功能是对网络通信进行实时捕获和深入分析,帮助用户理解网络流量、排查问题、进行安全审计以及优化网络性能。4.2.0版本是Wireshark的一...

    新课标2019_2020学年高中英语Unit1Womenofachievement课后作业3新人教版必修420200511047

    "Neither the students nor the teacher________________." "neither...nor..."连接两个主语时,遵循就近原则,"the teacher"是单数,所以用"knows the reason why she didn't turn up"。 - 句子4. "All 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 ...

Global site tag (gtag.js) - Google Analytics