Remove “Build path specifies execution environment…” warnings from Problems View

I have often workspaces with projects which specify Java 1.5 as minimal execution environment. On my machine there is no JDK 1.5 installed, and it turns out that getting one for Mac OSX Mountain Lion is not trivial. Actually I don’t need a JDK 1.5, since the standard 1.6 JDK is compatible. However, this raises in the workspace these annoying warnings.

screenshot 2013-05-17 um 10.32.31

In the Execution Environments setting it is possible to mark the Java 1.6 installation as compatible to the J2SE-1.5 Execution Environment:

screenshot 2013-05-17 um 10.52.31

Although the JDK 1.6 is marked compatible now, it is not “strictly compatible”, so the warning message remains.

Next you could try to disable the warning message. There is a setting for this in the preference dialog Java/Compiler/Building:

screenshot 2013-05-17 um 10.35.17

After changing the setting you are asked to rebuild the projects. But again, the warning do not disappear. I suspect this to be a bug and raised Bug#408317 for this.

So the last chance is to filter these warnings. Therefore select the options menu in the Problems View and open the “Configure Contents” dialog. In the “Types” selection tree expand the “Java Build Path Problems” node and uncheck “JRE System Library Problem”.

screenshot 2013-05-17 um 11.03.53

Finally the warning messages disappear from the Problems View. However, they are just filtered from the view, the projects themselves will still have these resource markers, so you will have a warning overlay icon on the project in the Package Explorer View although the Problems View might be empty.

But this raises the next problem: Now the warning disappears and the code is compiled with Java 1.6, and thus against the 1.6 API. This leads to the problem that you could accidently use API from >= 1.6. For example, usage of String#isEmpty() would compile even if the Execution Environment is set to J2SE-1.5 (the Execution Environment anyway just defines the lowest requirement) and also if Java source compatibility is set to 1.6 in the compiler settings.

We need to detect this unwanted use of API that is not 1.5 compatible. Therefore the PDE tooling offers support to install an Execution Environment Description for J2SE-1.5 and set up API tooling. This will finally allow us to detect illegal API use:

screenshot 2013-05-17 um 14.00.15

I like to thank Laurent Goubet and Mikael Barbero for their valuable comments on the potential API problems.


7 thoughts on “Remove “Build path specifies execution environment…” warnings from Problems View

  1. Well, the message is there for a reason: if you tell that your project can be run with JDK 1.5, but compile it with JDK 1.6 (even with “source” and “target” level set to 1.5), you might miss compilation errors.

    An easy example: create a new plug-in project that specifies 1.5 as its required environment, then create a single class like this :

    public class Test {
    public static void main(String[] args) {

    If you only have the JDK 6, this will compile fine. However, even if you’ve set the target level to “1.5”, that code will not run with the JDK 5 since “String.isEmpty()” has been introduced by 1.6. That’s what the warning tells you : if you need your code to be compatible with 1.5, you need to compile it with the JDK 1.5 to be on th safe side… or you need to perfectly know what methods cannot be used.

    • Laurent, thank you for the explanation. You are perfectly right, usage of String#isEmpty() would compile even when setting source compatibiliy to 1.5. So it is more or less just luck that I do not accidently use 1.6 API (String#isEmpty() I would not try to use since it is known to me that it is 1.6 API).

      So I am doomed, since I cannot install Java 1.5 for Mac OSX Mountain Lion 😦

      • Hi Karsten, long time since we don’t see each other πŸ™‚
        If I follow you correctly, in such a setup the code that Laurent suggest will compile with JDK 1.6, even if the target/source is set to 1.5. What happen then on execution time? I suppose, but just suppose, that the bytecode magic number will be set to 49 (more about this here:, and this will make this code compatible/runnable for JDK 1.5, but then this code will fail in the final client if he is using a JDK 1.5 (hopefully not because It has currently no support) with a NoClassDefFoundError/NoSuchMethodException or similar?

        It is quite hard to believe, such a problem would be only be found on execution and would be very hard to detect.


    • I did not know of that possibility, that’s quite nice to know when the JDK 5 is so hard to find :). Indeed, in with such help removing the warning can be done safely :).

    • That’s also a very valuable hint, Mikael! I was not aware of this. Thanks! I think I will update the post with that hint after trying this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s