Friday, February 26, 2010

Eclipse JRE configuration

Eclipse offers to configure the way we use JRE with eclipse per project in a few different places.
This is hard to remember when we don't use it so frequently, since we don't create project frequently as much as we create the files in them.
Hence this blog.

The first place where we can tell eclipse about different JREs we have in the system and make them available to eclipse for giving them to the projects in the workspace is
Window > Preferences > Java > Installed JREs
Here you can add as many different JREs you want to make available to different projects.
Out of the many, only one will be checked which will be the default JRE for new projects.

So how to change the JRE per project once it is created or checked out from version control?
Right click on the corresponding project and select properties
Java Build Path > Libraries
Here remove the default JRE and add the one you want via the Add Library... button.
Now this particular project will use a different (this new one) JRE from the others.

Ok, so instead of Sun JRE, this project is configured to use say IBM JRE, however I want to set the compliance level to 1.5 not 1.6.
In that case, select the Java Compiler from project properties.
Enable the checkbox for project specific settings.
And select the compliance level to be used for this project. Keep in mind the project JRE should support the compliance level opted for.

No comments :

Powered by Blogger.