Does Tomcat require JDK or JRE?

Jakarta EeTomcat

Jakarta Ee Problem Overview


I've read many articles and posts related to Tomcat and the Java runtime. I am confused and need help. Can anybody clear my doubt regarding whether Tomcat requires JDK or JRE?

Thanks in advance.

Jakarta Ee Solutions


Solution 1 - Jakarta Ee

Tomcat's RUNNING.txt which you can find in the root of the bundle states that Apache Tomcat requires Java Standard Edition Runtime Environment (JRE) to run. Minimum version of JRE depends on the version of Tomcat: for Tomcat 6.0 it is Java 5, for Tomcat 7.0 - Java 6.

However you can also use JDK because, as you probably know, it includes JRE (link). The only difference is in the configuration of environment variables. If you use JRE you should set JRE_HOME, if JDK - JAVA_HOME. Read RUNNING.txt for more details.

P.S. Web containers may require JDK in order to support JSP, because Java Compiler is required to compile Servlets which are generated from *.jsp files. Tomcat has Eclipse Java Compiler bundle so it can run on JRE and still support JSP.

Solution 2 - Jakarta Ee

The only notable difference using JDK over JRE is to enable debug mode when launching tomcat jvm.

in the RUNNING.txt we don't have clear distinction, the text deals with certain options, without telling which one :

> Using JAVA_HOME provides access to certain additional startup options > that are not allowed when JRE_HOME is used.

the information is inside catalina.sh script :

#   JAVA_HOME       Must point at your Java Development Kit installation.
#                   Required to run the with the "debug" argument.

Solution 3 - Jakarta Ee

I did successfully installation of Apache Tomcat 7.0.56 when I installed C:\Program Files (x86)\Java\jre1.8.0_171 .

Additional note: After I did successfully installation of Apache Tomcat 7.0.56 when I installed C:\Program Files (x86)\Java\jre1.8.0_171 I have seen in Java Control Panel -> Desktop Settings:

Web Enabled : checked 
Platform : 1.8 
Product : 1.8.0_171 
Architecture : x86 Type : 
User Path : C:\Program files (86)\Java\jre1.8.0_171\bin\javaw.exe 
Runtime Parametars : (empty field) 

Solution 4 - Jakarta Ee

I'm running TOMCAT 7.0.92.0 builted in XAMPP v3.2.4 installed in C:\XAMPP in a Windows 10.

I had installed JDK jdk-13.0.2 with the following environment variables set:

CATALINA_HOME = "C:\xampp\tomcat"
JAVA_HOME = "C:\Program Files\Java\jdk-13.0.2\"
JRE_HOME = "C:\Program Files\Java\jdk-13.0.2\" 

*Tried also without setting JRE_HOME and also pointing it at C:\Program Files\Java\jdk-13.0.2\bin\

But it wouldn't work until I installed JRE jre1.8.0_241 and set JRE_HOME to "C:\Program Files\Java\jre1.8.0_241"

Right now in XAMPP's Control Panel it shows the server at "Attempting to start Tomcat app..", and never shows it at running mode, but it's working.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJDGuideView Question on Stackoverflow
Solution 1 - Jakarta EeduemirView Answer on Stackoverflow
Solution 2 - Jakarta EebuzardView Answer on Stackoverflow
Solution 3 - Jakarta EeVladan UlardzicView Answer on Stackoverflow
Solution 4 - Jakarta EeJorge LizasoView Answer on Stackoverflow