How to change Java runtime environment for Tomcat in Eclipse
- Details
- Written by Nam Ha Minh
- Last Updated on 07 August 2019   |   Print Email
By default, an instance of Apache Tomcat is running under the same JRE that launches Eclipse (Workbench default JRE). For example, if your Eclipse IDE is running under JRE 7 (i.e. Eclipse Juno 4.2.2), then the newly added Tomcat instance (i.e. Tomcat v6.0) will run under JRE 7 as well. There would be a case in which we want to run Tomcat under different JRE version for a specific testing requirement. The following table illustrates this case:
Eclipse/Tomcat version | JRE version |
Eclipse Juno 4.2.2 | JRE 7 |
Tomcat v6.0 | JRE 6 |
How would we do that? Well, there are two ways to specify a specific JRE version for Tomcat in Eclipse: the first one is when adding new Tomcat instance, and the second one is configure an existing Tomcat instance.
1. Specify JRE version when adding new Tomcat instance
Right click in Servers view, select New > Server:
Select Tomcat v6.0 Server and click Next. In the next screen, specify Tomcat installation directory and choose specific JRE version under the JRE dropdown list:
Pick a desired JRE version, and then click Next or Finish. When starting Tomcat in Eclipse, we can spot the JRE version used in the Console view as follows:
2. Specify JRE version for an existing Tomcat instance
In this way, select Window > Preferences (or shortcut: Alt + W + P) from Eclipse’s main menu. In the Preferences dialog, expand the branch Server > Runtime Environments, select a Tomcat version in the Server runtime environments list, and click Edit button:
The dialog Edit Server Runtime Environment appears:
Pick a JRE version from the JRE dropdown list just like in the first way.
If you want to add a new JRE, click the Installed JREs button, and follow the steps described in this article: Managing JRE installations in Eclipse.
Related Tutorials:
Other Eclipse Tutorials:
- How to use Eclipse IDE for Java EE Developers
- How to create, build and run a Java Hello World program with Eclipse
- How to generate Javadoc in Eclipse
- How to create WAR file for Java web application in Eclipse
- How to create JAR file in Eclipse
- How to pass arguments when running a Java program in Eclipse
- How to create Java web project with Maven in Eclipse
- 25 Eclipse Shortcut Keys for Code Editing
- How to add custom Ant build script to Eclipse project
- How to Add Copyright License Header for Java Source Files in Eclipse
Comments