Warning - Build path specifies execution environment J2SE-1.4 - java

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?

In Eclipse from your project:
Right-click on your project
Click Properties
Java build path: Libraries; Remove the "JRE System Library[J2SE 1.4]"
Click Add Library -> JRE System Library
Select the new "Execution Environment" or Workspace default JRE

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>

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.

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

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.

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>

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.

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 :
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)
Check the new JRE, then Apply and close
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à

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.

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.

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

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

Related

JavaFX maven samples for CLI and IDE, what is the difference? [duplicate]

I use IntelliJ IDEA as my development environment, and Maven for dependency management. I frequently build my project structure (directories, poms, etc) outside of IDEA and then import the project into IDEA using Import project from external model. This works great, except that in my poms I specify that the maven-compiler-plugin should use JDK 1.6, and when I import, IDEA informs me that the Language Level Changed and that Language level changes will take effect on project reload, and then prompts to reload the project. This is annoying because I always use the same JDK version.
How do I change the default JDK that IntelliJ IDEA uses, so that I don't have to reload my project every time I import a new project?
This setting is changed in the "Structure for New Projects" dialog. Navigate to "File" -> "New Projects Setup" -> "Structure..."
Next, modify the "Project SDK" and "Project Language Level" as appropriate.
Previous versions of IntelliJ IDEA had this setting in "File" -> "Other Settings" -> "Default Project Structure...".
IntelliJ IDEA 12 had this setting in "Template Project Structure..." instead of "Default Project Structure..."
Download and unpack a JDK archive file (.tar.gz) and add it as a SDK in the 'Project Structure' dialog box ( Ctrl+Alt+Shift+S )
click on the gif to enlarge
Also make sure to set an appropriate 'Project language level'. I forgot to do that when creating the GIF.
Project Structure > Project > Project language level
For Java 8 set it to 8, for Java 9 set it to 9, and so on.
I am using IntelliJ IDEA 14.0.3, and I also have same question. Choose menu File \ Other Settings \ Default Project Structure...
Choose Project tab, section Project language level, choose level from dropdown list, this setting is default for all new project.
I have found out that in recent versions of IntelliJ IDEA requires Java 1.8 but is not configured by default.
We can change the path or configure from Project Settings > Project > Project SDK
here we can edit or add the JDK´s path.
(in my case the path is located in C:\Program Files\Java\jdk1.8.0_102)
Change JDK version to 1.8
Language level File -> project Structure -> Modules -> Sources -> Language level -> 8-Lambdas, type annotations etc.
Project SDk File -> project Structure -> Project 1.8
Java compiler File -> Settings -> Build, Executions, Deployment -> Compiler -> Java compiler
One other place worth checking: Look in the pom.xml for your project, if you are using Maven compiler plugin, at the source/target config and make sure it is the desired version of Java. I found that I had 1.7 in the following; I changed it to 1.8 and then everything compiled correctly in IntelliJ.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
The above responses were very useful, but after all settings, the project was running with the wrong version. Finally, I noticed that it can be also configured in the Dependencies window.
Idea 2018.1.3 File -> Project Structure -> Modules -> Sources and Dependencies.
To change the JDK version of the Intellij-IDE himself:
Start the IDE -> Help -> Find Action
than type:
Switch Boot JDK
or (depend on your version)
Switch IDE boot JDK
For latest version intellij, to set default jdk/sdk for new projects go to
Configure->Structure for New Projects -> Project Settings -> Project SDK
I am using IntelliJ 2020.3.1 and the File > Other Settings... menu option has disappeared. I went to Settings in the usual way and searched for "jdk". Under Build, Execution, Deployment > Build Tools > Maven > Importing I found the the setting that will solve my specific issue:
JDK for importer.
On my linux machine I use a script like this:
export IDEA_JDK=/opt/jdk14
/idea-IC/bin/idea.sh

Avoid the "no JREs installed in the workspace that are strictly compatible" warning in Eclipse for multiple Java versions

I know that there are already a lot of questions about this warning, but my question is a little bit different. I understand that I can use this configuration in my pom.xml to fix it
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
This gets rid of the warning, but only if I have Java 7 installed and configured in Eclipse. If for example I only have Java 8, I still see the warning unless I change the version in the configuration above to 1.8:
Build path specifies execution environment JavaSE-1.7. There are no
JREs installed in the workspace that are strictly compatible with this
environment.
My project is compatible with Java 7, 8, 9 and 10. What I want to achieve is to avoid this warning if any of these versions of Java is installed without changing the version in my pom.xml to match the currently installed Java version every time. Something to tell Eclipse that Java 7 or anything above is good.
The project still compiles and works fine with the warning, it's just distracting as it marks the project as having issues. I know that I can hide this type of warnings in Eclipse settings, but is there a way to get rid of it by only using some configuration in pom.xml?
Eclipse uses the value <target>1.7</target> to decide which execution environment to include in the build path, as part of its Maven integration.
The execution environments are mapped to JREs installed in Eclipse (i.e. referenced in Preferences > Java > Installed JREs).
The mapping itself is configured in Preferences > Java > Installed JREs > Runtime Environments. Eclipse will automatically match an execution environment (e.g. JavaSE-1.7) to an installed JRE (e.g. jdk1.7.0_80). If there is no exact match for the execution environment specified in your project, it will give you a warning like the one you're getting.
Therefore, to get rid of the warning, you must either:
Install the Java version that is an exact match for your <target> (i.e. jdk1.7) and add it under Preferences > Java > Installed JREs > Runtime Environments
Configure the Java version in your pom to one for which there is an exact match
My project is compatible with Java 7, 8, 9 and 10. What I want to achieve is to avoid this warning if any of these versions of Java is installed
When configuring the execution environment to use, Eclipse only cares for the <target> value. You need to make sure that there is a JRE installed in Eclipse whose version is a perfect match for the value of that property. Otherwise, the warning will not go away, period.
I don't have the intention to target some specific version, the default target would work fine for me.
No, it wouldn't, because the default target is 1.5. Target configuration is a non-optional configuration property, there is no 'target everything' option.
You could remove the Maven-configured execution environment from the build path and add a JRE directly (project properties > Java Build Path > Libraries > Add library... > JRE System Library > Alternate JRE). This will also make the warning go away, but it will be back as soon as you run Maven project update. Such a configuration shouldn't really be used, as it ties your project to a specific installation of Java on your machine.

Eclipse Default JRE Preference Installed JRE Not Working

I went to the Preference of Eclipse and changed the default JRE to the Java SE 8, and also changed the Compiler settings of Eclipse to be 1.8 JDK compliance. I even removed the other JREs.
However, when I import a project, as you can see from the Project Explorer, the project name is "SpringService", somehow the JRE System Library is JavaSE-1.6 and they are still using 1.6 as default!
Can anyone tell me what I did wrong? Otherwise every new project I have to manually go to the properties and change it manually! Hate it!
This post might be relevant to enter link description here SO question.
When you set your Installed JREs preference, you want to select the root directory of a full Java Development Kit installation, not just a bare JRE installation. Eclipse needs access to the supporting libraries that are bundled with a full JDK, but absent from a base JRE install.
Also, if you are importing a project, do you mean that you are importing an existing, pre-configured Eclipse project? Or just the directory structure that contains the source code? If you are importing an existing Eclipse project, it may have already been set up with project-specific settings (it's hard to give advice with being able to poke around in the settings).
Check the plugin section in the pom.xml to see if it contains the following entry.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
This will overwrite the default preference. A lot of maven project archetype uses 1.6. Just change them to 1.8 and do a Maven->Update Project.
U can you 'Build Path' on the project ,then remove the jre1.6, add the user libiary .

Maven 3.3.1 ECLIPSE: -Dmaven.multiModuleProjectDirectory system propery is not set

I just installed Maven 3.3.1 on Mac OS X, and building a Maven Project with Eclipse is giving me this error:
-Dmaven.multiModuleProjectDirectory system property is not set.
Check $M2_HOME environment variable and mvn script match.
It did not happen before with Maven 3.2.5.
Is there any way to fix this (except downgrading to 3.2.5) ?
Where exactly can I set this "multiModuleProjectDirectory" property in Eclipse?
In Eclipse you need to go like this.
Window-> Preference -> Java -> Installed JREs -> Edit
In the edit Default VM arguments you need to put
If you already set the maven home.
-Dmaven.multiModuleProjectDirectory=$M2_HOME
In IntelliJ you can set this option in VM Options field that you can find in the next configuration view:
Preferences/Build, execution, deployment/Build tools/Maven/Runner
This was filed as a bug with m2e in Eclipse at https://bugs.eclipse.org/bugs/show_bug.cgi?id=462944 , due to the changes in Maven 3.3.1.
This is fixed in m2e 1.5.2 as of 2015-04-13. This is an available release that can be installed from http://download.eclipse.org/technology/m2e/releases/ .
(No more changing JVM arguments for the entire workspace or for specific launch configurations required.)
Define like this in the JVM options:
-Dmaven.multiModuleProjectDirectory=HOME_PATH_OF_YOU_PROJECT
In case you have this error message on your commandline, please verify if your PATH variable points to the same maven installation apache-maven-3.X.X/bin folder as your M2_HOME variable. In my case I was mixing up two versions which resulted in this error.
go to run configuration, create new maven build launch configuration where in the first tab you fill the base directory and the goal,
then, go to jre tab and add to the vm args this config:
-Dmaven.multiModuleProjectDirectory=%M2_HOME%
where M2_HOME is an environment variable pointing to the base directory of your maven installation
If you want to try a second way, you can try to download a path from http://download.eclipse.org/technology/m2e/milestones/1.5/.
Open Help>install new software and download from url above. This way solved my problem.
I encountered the same issue with Maven 3.3 and 3.2 versions, so I decided to downgrade it to version 3.0.5 and it worked just fine.
To set the maven.multiModuleProjectDirectory property permanently in Maven, I've added a default activated profile which initializes the property with the MAVEN_HOME environment variable in the settings.xml file. Or you could also alternatively use the M2_HOME environment variable.
<profile>
<id>my-profile</id>
<properties>
<maven.multiModuleProjectDirectory>${env.MAVEN_HOME}</maven.multiModuleProjectDirectory>
</properties>
</profile>
<activeProfiles>
<activeProfile>my-profile</activeProfile>
</activeProfiles>
i had the same problem with intelliJ 14, i tried out different solutions provided at forums but not worked out. What i did is i completely uninstall intellij and installed intellij 15.0.1 and import the same project then all works fine.

How do I change the IntelliJ IDEA default JDK?

I use IntelliJ IDEA as my development environment, and Maven for dependency management. I frequently build my project structure (directories, poms, etc) outside of IDEA and then import the project into IDEA using Import project from external model. This works great, except that in my poms I specify that the maven-compiler-plugin should use JDK 1.6, and when I import, IDEA informs me that the Language Level Changed and that Language level changes will take effect on project reload, and then prompts to reload the project. This is annoying because I always use the same JDK version.
How do I change the default JDK that IntelliJ IDEA uses, so that I don't have to reload my project every time I import a new project?
This setting is changed in the "Structure for New Projects" dialog. Navigate to "File" -> "New Projects Setup" -> "Structure..."
Next, modify the "Project SDK" and "Project Language Level" as appropriate.
Previous versions of IntelliJ IDEA had this setting in "File" -> "Other Settings" -> "Default Project Structure...".
IntelliJ IDEA 12 had this setting in "Template Project Structure..." instead of "Default Project Structure..."
Download and unpack a JDK archive file (.tar.gz) and add it as a SDK in the 'Project Structure' dialog box ( Ctrl+Alt+Shift+S )
click on the gif to enlarge
Also make sure to set an appropriate 'Project language level'. I forgot to do that when creating the GIF.
Project Structure > Project > Project language level
For Java 8 set it to 8, for Java 9 set it to 9, and so on.
I am using IntelliJ IDEA 14.0.3, and I also have same question. Choose menu File \ Other Settings \ Default Project Structure...
Choose Project tab, section Project language level, choose level from dropdown list, this setting is default for all new project.
I have found out that in recent versions of IntelliJ IDEA requires Java 1.8 but is not configured by default.
We can change the path or configure from Project Settings > Project > Project SDK
here we can edit or add the JDK´s path.
(in my case the path is located in C:\Program Files\Java\jdk1.8.0_102)
Change JDK version to 1.8
Language level File -> project Structure -> Modules -> Sources -> Language level -> 8-Lambdas, type annotations etc.
Project SDk File -> project Structure -> Project 1.8
Java compiler File -> Settings -> Build, Executions, Deployment -> Compiler -> Java compiler
One other place worth checking: Look in the pom.xml for your project, if you are using Maven compiler plugin, at the source/target config and make sure it is the desired version of Java. I found that I had 1.7 in the following; I changed it to 1.8 and then everything compiled correctly in IntelliJ.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
The above responses were very useful, but after all settings, the project was running with the wrong version. Finally, I noticed that it can be also configured in the Dependencies window.
Idea 2018.1.3 File -> Project Structure -> Modules -> Sources and Dependencies.
To change the JDK version of the Intellij-IDE himself:
Start the IDE -> Help -> Find Action
than type:
Switch Boot JDK
or (depend on your version)
Switch IDE boot JDK
For latest version intellij, to set default jdk/sdk for new projects go to
Configure->Structure for New Projects -> Project Settings -> Project SDK
I am using IntelliJ 2020.3.1 and the File > Other Settings... menu option has disappeared. I went to Settings in the usual way and searched for "jdk". Under Build, Execution, Deployment > Build Tools > Maven > Importing I found the the setting that will solve my specific issue:
JDK for importer.
On my linux machine I use a script like this:
export IDEA_JDK=/opt/jdk14
/idea-IC/bin/idea.sh

Categories

Resources