By default, Eclipse uses the JRE on which it is running, as the default JRE for workspaces and Java projects. In practice, we may need several JRE versions for different testing purposes. Eclipse allows us to manage different installations of JRE and doing so is pretty easy.

Of course you must have different JREs installed on your computer first (for example: JRE 5, JRE 6, and JRE 7). In Eclipse, click Window > Preferences from main menu (or shortcut: Alt + W + P). In the Preferences dialog, expand the branch Java > Installed JREs:

Eclipse preferences - installed JREs

As we see, Eclipse lists all JREs in the Installed JREs table with the default one checked. Note that Eclipse does not scan all installed JREs automatically (except the default one that runs Eclipse itself), so we have to add/remove other JRE versions manually here.

To add an installed JRE version to the table, click Add button. The Add JRE dialog appears:

Add JRE dialog

Select Standard VM (default selected), then click Next. In the next screen, JRE Definition, click Directory button to locate installation directory of the desired JRE:

JRE Definition screen

Wait a few seconds for Eclipse loading JRE system libraries jar files, and then click Finish. The newly added JRE is shown in the table:



newly added JRE

If you want to use the newly added JRE as the default, select the appropriate checkbox.

To edit or remove a JRE, click the corresponding button Edit or Remove.

 

NOTES:

    • You can pick a JDK installation directory instead of a JRE one, as Eclipse can load the JRE inside a JDK installation.
    • When you change the default JRE, it does not affect the existing projects in workspace. The change will apply for the new projects only.
    • The installed JREs configuration is per workspace. That means different workspaces may have different set of installed JREs.  

Other Eclipse Tutorials:


About the Author:

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.



Add comment