gpt4 book ai didi

java - 为什么 Tomcat8.exe 启动的 JAVA_HOME 与 Windows 环境变量中设置的 JAVA_HOME 不同?

转载 作者:行者123 更新时间:2023-11-28 22:35:28 31 4
gpt4 key购买 nike

我在 Windows 10 中遇到了 Tomcat8.exe 这种奇怪的情况。

我在Windows系统环境下定义的JAVA_HOME环境变量指向JDK 1.8路径:

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65

当我运行“C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\Tomcat8.exe”时,服务器以另一个 JDK 启动,如我在 catalina.log 中所见:

12-May-2016 08:57:28.250 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.30
12-May-2016 08:57:28.253 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 1 2015 22:30:46 UTC
12-May-2016 08:57:28.254 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.30.0
12-May-2016 08:57:28.254 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8
12-May-2016 08:57:28.255 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.2
12-May-2016 08:57:28.255 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
12-May-2016 08:57:28.255 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.7.0_79\jre
12-May-2016 08:57:28.256 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_79-b15
12-May-2016 08:57:28.256 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
12-May-2016 08:57:28.256 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
12-May-2016 08:57:28.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.0
12-May-2016 08:57:28.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
12-May-2016 08:57:28.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 8.0
12-May-2016 08:57:28.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
12-May-2016 08:57:28.261 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp
12-May-2016 08:57:28.261 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
12-May-2016 08:57:28.262 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\logging.properties
12-May-2016 08:57:28.264 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
12-May-2016 08:57:28.265 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
12-May-2016 08:57:28.266 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
12-May-2016 08:57:28.267 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_65\bin;.

我不明白“Java Home: C:\Program Files\Java\jdk1.7.0_79\jre”的来源。

我尝试在所有 Tomcat 文件和子文件夹中的文件搜索中查找“1.7”,唯一出现在日志中...

链接的目标是“C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\Tomcat8.exe”,没有其他变量。

此外,JDK 1.7 不在系统路径中!

如何强制使用 JDK 1.8?

提前致谢。

编辑

这是设置命令在提示符下的打印:

C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Alessandro\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=ASUS-B551L-09
ComSpec=C:\WINDOWS\system32\cmd.exe
configsetroot=C:\WINDOWS\ConfigSetRoot
DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Alessandro
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65
LOCALAPPDATA=C:\Users\Alessandro\AppData\Local
LOGONSERVER=\\ASUS-B551L-09
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\GTK2-Runtime\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.8.0_65\bin;C:\Program Files\Git;C:\Program Files\7-Zip;C:\Program Files\nodejs\;C:\Program Files\Docker Toolbox;C:\Users\Alessandro\AppData\Roaming\npm
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=4501
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\Alessandro\AppData\Local\Temp
TMP=C:\Users\Alessandro\AppData\Local\Temp
USERDOMAIN=ASUS-B551L-09
USERDOMAIN_ROAMINGPROFILE=ASUS-B551L-09
USERNAME=Alessandro
USERPROFILE=C:\Users\Alessandro
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
windir=C:\WINDOWS

最佳答案

感谢 Jacek Cz,我找到了解决方案。

这是 Tomcat 的配置,在面板中可见,可以从以下位置启动:

“Windows 图标/所有应用程序/Apache Tomcat 8/配置”

转到 Java 选项卡,设置了 JDK 1.7。更改此变量后,Tomcat 会以正确的 JDK 启动。

Apache Tomcat 8.0 Tomcat8 Properties

关于java - 为什么 Tomcat8.exe 启动的 JAVA_HOME 与 Windows 环境变量中设置的 JAVA_HOME 不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37180393/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com