Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify JRE/JDK when starting Apache Tomcat 7

Is there a way to tell Tomcat 7 the path to the JVM that must be used? For example:

startup --jvm /path/to/my/jvm
like image 606
MauroPorras Avatar asked May 05 '12 01:05

MauroPorras


People also ask

Does Tomcat require JRE or JDK?

Apache Tomcat requires 64-bit Java/OpenJDK. If you have multiple Java versions installed on your system, we recommend that you uninstall older Java versions and keep only the latest supported Java version.

How can I change Java path in Tomcat?

We can change the JRE for Tomcat by setting the JRE_HOME variable in a script file called setenv. bat (on Windows) or setenv.sh (on *nix). This file does not exist by default, so create such file and place it under CATALINA_BASE\bin directory (CATALINA_BASE is the Tomcat installation directory).

What version of Java does Tomcat 7 use?

Building Apache Tomcat requires a Java 6 JDK to be installed and optionally a Java 7 JDK installed in parallel with Java 6 one. The Java 7 JDK is only required if you wish to build Tomcat with JSR-356 (Java WebSocket 1.1) support.

Can Tomcat work with JRE?

Tomcat has Eclipse Java Compiler bundle so it can run on JRE and still support JSP.


1 Answers

A more flexible approach is to create a file named setenv.bat / setenv.sh (pick the right one for your platform) in $CATALINA_BASE/bin and set JAVA_HOME there. That way it only affects Tomcat, not anything else you are running. It also makes it easy to run multiple different Tomcat installations on different JVMs.

like image 51
Mark Thomas Avatar answered Oct 13 '22 11:10

Mark Thomas