简体   繁体   中英

Why Tomcat8.exe starts with a JAVA_HOME that is different from JAVA_HOME setted in Windows environment variables?

I have this strange situation with Tomcat8.exe in Windows 10.

My JAVA_HOME environment variable defined in Windows System environment points at JDK 1.8 path:

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

When I run "C:\\Program Files\\Apache Software Foundation\\Tomcat 8.0\\bin\\Tomcat8.exe", the server starts with another JDK, as I can see in 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;.

I don't understand the source of "Java Home: C:\\Program Files\\Java\\jdk1.7.0_79\\jre".

I tried a find in files search of "1.7" in all Tomcat files and subfolders, the only occourence appears in the logs...

The destination of the link is "C:\\Program Files\\Apache Software Foundation\\Tomcat 8.0\\bin\\Tomcat8.exe", there are no others variables.

Furthermore, the JDK 1.7 is not in the system Path!

How can I force the JDK 1.8?

Thanks in advance.

EDIT

This is the print of set command in prompt:

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

I guess JAVA_HOME variables is getting overridden by tomcat.

Please check startup.bat and catalina.bat files to check if JAVA_HOME variable is defined which I guess will be defined there.

Please check those files under tomcat bin folder.

When started as a Windows service (in a typical Windows installation), Tomcat gets the JVM path from the Java tab, visible from systray/configure.

All Java paths for Tomcat depend on this main path.

I guess, the sense of such design is: after Java upgrade Tomcat can run with old, checked JVM, until admin modify.

Thanks to Jacek Cz, I have found the solution.

This was the configuration of Tomcat, visible in the panel that can be launched from:

"Windows Icon / All Apps / Apache Tomcat 8 / Configure"

Going to the tab Java, there was setted the JDK 1.7. Changing this variable, Tomcat starts with the correct JDK.

Apache Tomcat 8.0 Tomcat8属性

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM