Tomcat doesn't use latest Java version

I have Java 8 v171. Few month ago, I have installed Tomcat 8.5.50. Now, I need to upgrade my Java version.

Now, I have Java 8 v171 and Java 8 v301.

Output of java -version:

java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)

I set JAVA_HOME and JRE_HOME. Output of echo "%JAVA_HOME% / %JRE_HOME%":

"D:\Software\Java\jdk1.8.0_301 / D:\Software\Java\jre1.8.0_301"

But, Tomcat stays at the old version. Catalina log file keep old JVM version. Wen I manually run a new instance of it with my account, it show the new java version.

But it's actually running in Windows service. Even when I restart it (thanks to restart button or stop/start) it always come back with old JVM.

How can I use new Java version ?


As you installed it as a service, you need to specify the java-version in the file: Tomcat8.5.50w.exe which is located in the installation directory.

It may vary a bit depending on your version, but should (in case) still be pretty straight forward!

  1. Stop the service
  2. Go to the installation directory
  3. Open "Tomcat8.5.50w.exe"
  4. Navigate to "Java"-tab
  5. Edit the first input field right after "Java Virtual Machine" to point to your new installation
  6. Start the service