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:

add new Tomcat instance in Eclipse

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:

choose JRE version for Tomcat

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:



JRE version in Console view

 

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:

Choose JRE version for Tomcat in Eclipse Preferences

The dialog Edit Server Runtime Environment appears:

choose JRE version for Tomcat 2

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:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment