Lỗi build path specifies execution environment javase-1.6

When I open eclipse I got 1 Java Build Path Problem: Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment.

Now I tried looking through the answers and other question, but all the answers are based on the already acquired knowledge about programming and such. Please help me fix this problem step by step.

Lỗi build path specifies execution environment javase-1.6

asked Jun 17, 2012 at 12:19

2

Your problem is that the Eclipse project is already configured to work on version 6 of the system libraries. You however do not seem to have this specific version, therefore you need to reconfigure the build path for the project.

In order to change your JRE System Library, you must

  1. Go to Project|Properties
  2. Choose the Java Build Path section
  3. Select the current JRE System Library, and choose Remove
  4. Select Add Library, and under the JRE System Library category pick your system library; you probably just need to choose the Workspace default JRE

If the default JRE version is <= 4, you most likely will have problems building the project. In that case I suggest you install a more recent JRE.

More generally, under Window|Preferences, you can check Java|Installed JREs|Execution Environments to know which of the installed JREs match a specific execution environment. Should be pretty clear, but that page demystifies things a bit.

Joerg Hohwiller 2012-03-01 16:40:33 EST

Build Identifier: 20110916-0149 I get this Warning: Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. Observation: m2e decides the JRE based on the source/target settings of the maven-compiler-plugin. Problem: This behavior of m2e is simply wrong. It is a regular usecase that you use a particular JDK/JRE but compile your code downward compatible. Even worse in one project I am providing a particular OSS library that has a few features that are only available in Java1.6 however the majority of the code is working with Java1.5. Developers in that project that also had a JDK1.5 declared in Eclipse together with JDK1.6 got compile errors because m2e automatically switched the JRE_CONTAINER. IF you do not have that JDK/JRE declared you get a warning in Eclipse that you cannot prevent. I am investing all my energy to make the development teams reduce warnings to 0. If there are permanent warnings then new warnings are not taken serious (broken window effect). Therefore in all these cases I am force to get rid of m2e and go back to maven-eclipse-plugin. Suggestion: m2e should never generate such entry by default: <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.x"/> Only if "compilerVersion" is specified for maven-compiler-plugin then this entry can be generated based on that value. Reproducible: Always Steps to Reproduce:

  1. use m2e
  2. set source and target in maven-compiler-plugin to something lower than JRE/JDK version

Igor Fedorenko 2012-03-01 17:33:52 EST

Although I agree compiler source/target version does not necessary imply particular Java standard library version, there is a strong correlation between the two and current m2e heuristics work well for majority of projects. Having no EE specified, as you suggest, will force all m2e projects use workspace default JRE, which I believe is much worse alternative and will result in compilation errors due to JRE libraries mismatch for a much larger proportion of the projects. The root problem here is the lack of "target JRE" notion in Maven core and until this is solved guessing JRE from compiler source/target is the best (or only?) option available. Please note that in m2e 1.1 it is possible to manually override project target JRE in Java Build Path properties, and selected JRE is expected to survive Project Configuration Update (see bug 353266).

Joerg Hohwiller 2012-03-02 09:57:31 EST

(In reply to [comment

1](https://bugs.eclipse.org/bugs/show%5Fbug.cgi?id=373023

c1))
Although I agree compiler source/target version does not necessary imply

particular Java standard library version, there is a strong correlation between the two and current m2e heuristics work well for majority of projects.

Having no EE specified, as you suggest, will force all m2e projects use workspace default JRE, which I believe is much worse alternative and will result in compilation errors due to JRE libraries mismatch for a much larger proportion of the projects.

The root problem here is the lack of "target JRE" notion in Maven core and until this is solved guessing JRE from compiler source/target is the best (or only?) option available.

Please note that in m2e 1.1 it is possible to manually override project target JRE in Java Build Path properties, and selected JRE is expected to survive Project Configuration Update (see bug 353266). Thanks for the quick hint. I will upgrade to 1.1 and see if that works as expected. However, I still think my suggestion would fit better: Only if "compilerVersion" is specified for maven-compiler-plugin then this entry can be generated based on that value. That would be the right solution for "The root problem here is the lack of "target JRE" notion". However, I understand that there is some backward compatibility issue with m2e then.

Igor Fedorenko 2012-03-02 11:41:22 EST

(In reply to [comment

2](https://bugs.eclipse.org/bugs/show%5Fbug.cgi?id=373023

c2))
However, I still think my suggestion would fit better:
Only if "compilerVersion" is specified for maven-compiler-plugin then this

entry can be generated based on that value. That would be the right solution for "The root problem here is the lack of "target JRE" notion". However, I understand that there is some backward compatibility issue with m2e then. In this case <executable> maven-compiler-plugin is the right way to find system libraries, not <compilerVersion>. If you are interested in adding support for <executable>, please provide a quality patch and we'll review and apply it.

Joerg Hohwiller 2012-04-12 07:57:42 EDT

(In reply to [comment

1](https://bugs.eclipse.org/bugs/show%5Fbug.cgi?id=373023

c1))
Please note that in m2e 1.1 it is possible to manually override project target

JRE in Java Build Path properties, and selected JRE is expected to survive Project Configuration Update (see bug 353266). I upgraded to m2e version 1.1.0.20120130-2016 Then I changed JRE for a project manually and the warning went away. When I do "Maven > Update Project..." then the warning comes back. (same problem as with previous version of m2e) So IMHO there is still no workaround available. If I have 80+ Modules and have to do "Update Project..." from time to time the only way I see right now is to live with the warning or to build with the wrong JRE (or get rid of m2e). If there is a workaround but I did not properly understand how to tweak the config please let me know.

Igor Fedorenko 2012-04-12 11:28:27 EDT

I've opened bug 376619 to track the problem with manually set JRE version getting result during project update in 1.1.

Joerg Hohwiller 2012-06-17 07:00:57 EDT

FYI: It is not only this single warning. I now additionally get tons of warnings like this: Access restriction: The type PostConstruct is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar

Joerg Hohwiller 2012-06-17 07:09:17 EDT

I found a simple workaround until the actual problem is fixed: <profiles>

<profile>
  <id>eclipse.profile</id>
  <activation>
    <property>
      <name>eclipse.application</name>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
           <source>1.6</source>
           <target>1.6</target>
         </configuration>
      </plugin>
    </plugins>
  </build>
</profile>    
</profiles>

Jörg Hohwiller 2016-08-06 17:49:36 EDT

Still as of today you get an ugly warning from m2e in this case and there is no way to get rid of it. Warnings should only appear where there is something wrong that you have to work on. If it is normal that your project is marked with a warning you get used to it and do not take warnings for serious. This is a big problem in Eclipse as it is too noisy because of such "bugs".

Jörg Hohwiller 2016-08-06 17:52:31 EDT

m2e offers a config with Errors/Warnings. A very simple solution would be to add a checkbox with "supress build path execution environment not strictly compatible" that would suppress the warning.