153

I create a Maven project in Eclipse Helios. It works fine for a day, but then this warning shows up:

Build path specifies execution environment J2SE-1.4. There are no JREs installed in the workspace that are strictly compatible with this environment.

Since this message, the project stopped compiling and debugging. Does anyone have solution for this problem?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
narsereg
  • 1,553
  • 2
  • 11
  • 7

12 Answers12

243

In Eclipse from your project:

  1. Right-click on your project
  2. Click Properties
  3. Java build path: Libraries; Remove the "JRE System Library[J2SE 1.4]"
  4. Click Add Library -> JRE System Library
  5. Select the new "Execution Environment" or Workspace default JRE
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
btpka3
  • 3,720
  • 2
  • 23
  • 26
  • 44
    This answer is right for Eclipse, but wrong for Maven + Eclipse – Chris Dolan Jul 25 '11 at 21:01
  • 20
    This will temporarily fix the problem, until another maven build is run, at which point the JRE version will be reset to the default. See Pascal Thivent's answer to change the default version of the JRE specified in the POM. – matthewb May 31 '12 at 20:12
  • All not working. Whenever you do [Alt][F5] to update maven config all such manual tweaks get lots and the warning comes back. See bugs.eclipse.org/bugs/show_bug.cgi?id=376619 – Jörg Oct 31 '16 at 16:22
  • Using Eclipse 2020-09, you will need to select "Modulepath" before the "Add Library..." button becomes enabled. This may depend on what version of Java you have installed. Java is in such a state of flux. I am using OpenJDK Corretto-11.0.9. – Richard Jessop Nov 28 '20 at 17:42
188

Whether you're using the maven eclipse plugin or m2eclipse, Eclipse's project configuration is derived from the POM, so you need to configure the maven compiler plugin for 1.6 (it defaults to 1.4).

Add the following to your project's pom.xml, save, then go to your Eclipse project and select Properties > Maven > Update Project Configuration:

<project>
 <build>
  <pluginManagement>
   <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>
  </pluginManagement>
 </build>
</project>
Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 4
    I agree, this is the correct answer. Many of the other solutions will temporarily resolve the problem, until another Maven build is run, at which point the JRE will be reset to the default version. Adding this plugin to the POM changes the default JRE version. – matthewb May 31 '12 at 20:11
  • Where (full XPATH location) in the pom.xml does this go? Wherever I add it, Maven complains of a malformed pom. – Ed Randall Jul 03 '12 at 11:49
  • 2
    This is the correct answer. The accepted answer is a temporary fix! – Scott Offen Aug 23 '12 at 21:11
  • @EdRandall please check http://maven.apache.org/plugins/maven-compiler-plugin/usage.html – Martin Dürrmeier Nov 26 '13 at 17:33
  • I have this in my maven pom.xml and STILL get the warning. Everything seems to work but the warning is still there – ropo Jan 25 '16 at 11:32
  • @ropo I think the current maven doesn't require the `` tags. – Maarten Bodewes Apr 28 '16 at 09:32
  • The default Java version depends on maven-compiler-plugin's version. The current version defaults to 1.7: https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#source Also, this assumes the problem is a too old Java version. The solution would differ if the build path is correct. – Philippe Cloutier Dec 20 '22 at 23:40
11

The above solutions fix the project or work around the problem in some way. Sometimes you just don't want to fix the project and just hide the warning instead.

To do that, configure the contents of the warning panel and make sure to toggle-off the "build path"->"JRE System Path Problem" category. The UI for this dialog is a bit complex/weird/usability challenged so you might have to fiddle with a few of the options to make it do what you want.

Niroshan Ratnayake
  • 3,433
  • 3
  • 20
  • 18
Jilles van Gurp
  • 7,927
  • 4
  • 38
  • 46
  • I have two Workspaces set-up the same way with a JDK 7 but compiling to 1.6 (we'll move over eventually). Machine was hard shut down by good old Windows Update - and the Workspace which was open started showing this and wouldn't be mollified. Thanks for pointing out a work around! – RedYeti Apr 12 '13 at 13:26
  • 16
    Or another slightly cleaner way: Window -> Preferences -> Java -> Compiler -> Building -> Set "No strictly compatible JRE for execution environment" to "Ignore" – RedYeti Apr 12 '13 at 13:33
  • @RedYeti this should work but it's not for me (Eclipse 4.5) – NathanChristie Sep 02 '15 at 16:02
4

In eclipse preferences, go to Java->Installed JREs->Execution Environment and set up a JRE Execution Environment for J2SE-1.4

krock
  • 28,904
  • 13
  • 79
  • 85
  • This will temporarily fix the problem, until another maven build is run, at which point the JRE version will be reset to the default. See Pascal Thivent's answer above to change the default version of the JRE specified in the POM. – matthewb May 31 '12 at 20:12
  • No, this is changing the workspace installed JREs and not the one for the specific project (which is what the accepted answer had) – AlBlue Feb 01 '14 at 18:15
3

The actual cause of this warning is that you have configured your project to run with an earlier JRE version then you have installed. Generally this occurs whenever you use old projects with newer JREs.

This will likely cause no trouble at all. But if you want to be really on the save side, you should install the correct, old JDK. You can find them here: http://www.oracle.com/technetwork/java/archive-139210.html

If you then restart eclipse you can go into Window > Preferences > Java > Installed JREs > Execution Environments and set for in your case J2SE-1.4 the [perfect match] as eclipse calls it.

Christian
  • 1,341
  • 1
  • 16
  • 35
3

If you have Java 1.8 then

You need this xml part in pom.xml and update project.

 <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
N..
  • 906
  • 7
  • 23
2

the correct procedure to resolve this warning, as other people write, is to go inside your project Properties and click on Java Build Path located on the left. Now you will find inside the Libraries Window the J2SE 1.5, double click on this one and a new window will give you the possibility to choose the correct Excecution Environment. Now select your version and the warning will disappear.

cyberdemon
  • 43
  • 2
  • 10
2

I met the same warning in STS (Spring Tool Suite), if it may help someone somehow.

This is the source https://www.baeldung.com/eclipse-change-java-version, and here's a summary of it :

Warning : build path specifies execution environment javase-11. there are no jres installed in the workspace that are strictly compatible with this environment.

Environment : Ubuntu 20.04 (with default OpenJDK11) STS 4

To solve the warning :

  1. Change the JRE of the workspace of STS (By default, STS uses the JRE embedded in its plugins) : Window>Preferences>Installed JREs>Add>Standard VM>Directory (browse to your openjdk folder, in my case /usr/lib/jvm/java-11-openjdk-amd64)>Finish)
  2. Check the new JRE, then Apply and close
  3. Now configure the spring-boot project to use the newly added JRE : Right click on the project > properties > Java Build Path > in Libraries tab > Remove the old JRE, then in Modulepath Add Library > JRE System Library > Environments (choose JavaSE-11, make sure to check it on the right panel, mentionned "perfect-match"), Apply and Close

And voilà

Inasa
  • 21
  • 1
1

Did you setup your project to be compiled with 1.4 compliance? If so, do what krock said. Or to be more exact you need to select the J2SE-1.4 execution environment and check one of the installed JRE that you want to use in 1.4 compliance mode; most likely you'll have a 1.6 JRE installed, just check that one. Or install a 1.4 JRE if you have a setup kit, and use that one.

Otherwise go to your Eclipse preferences, Java -> Compiler and check if the compliance is set to 1.4. If it is change it back to 1.6. If it's not go to the project properties, and check if it has project specific settings. Go to Java Compiler, and uncheck that if you want to use the general eclipse preferences. Or set the project specific settings to 1.6, so that it's always 1.6 regardless of eclipse preferences.

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Andrei Fierbinteanu
  • 7,656
  • 3
  • 31
  • 45
  • This will temporarily fix the problem, until another maven build is run, at which point the JRE version will be reset to the default. See Pascal Thivent's answer above to change the default version of the JRE specified in the POM. – matthewb May 31 '12 at 20:13
0

Just change the version in Window-> Preferences-> Java -> Installed JREs. Check the installed JREs list. Then, Right-click on your project -> properties -> Java build path -> libraries. Change the "JRE System Library" to the version in "installed JREs".

The warning will be gone.

Ankitha J
  • 124
  • 1
  • 5
-2

I was getting project warning as "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment". I removed the J2SE1.5 library and added new JRE System Library which resolved my problem

-2

Expand your project in work space>>Right click(JRE System Libraries)>>select properties>>selectworkspace default JRE the above solution sol

Akhil
  • 1
  • 3