- 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:
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on
Facebook and watch
his Java videos you YouTube.