Java 警告 - 构建路径指定执行环境 J2SE-1.4
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3138384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Warning - Build path specifies execution environment J2SE-1.4
提问by narsereg
I create a Maven project in Eclipse Helios. It works fine for a day, but then this warning shows up:
我在 Eclipse Helios 中创建了一个 Maven 项目。它可以正常工作一天,但随后出现此警告:
Build path specifies execution environment J2SE-1.4. There are no JREs installed in the workspace that are strictly compatible with this environment.
构建路径指定执行环境 J2SE-1.4。工作空间中没有安装与此环境严格兼容的 JRE。
Since this message, the project stopped compiling and debugging. Does anyone have solution for this problem?
由于此消息,项目停止编译和调试。有没有人有解决这个问题的方法?
采纳答案by btpka3
In Eclipse from your project:
在您项目的 Eclipse 中:
- 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
- 右键单击您的项目
- 单击属性
- Java 构建路径:库;删除“JRE 系统库[J2SE 1.4]”
- 单击添加库-> JRE 系统库
- 选择新的“执行环境”或工作区默认 JRE
回答by krock
In eclipse preferences, go to Java->Installed JREs->Execution Environment and set up a JRE Execution Environmentfor J2SE-1.4
在 eclipse 首选项中,转到 Java->Installed JREs->Execution Environment 并为 J2SE-1.4设置 JRE执行环境
回答by Andrei Fierbinteanu
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.
您是否将项目设置为使用 1.4 合规性进行编译?如果是这样,就按照克罗克说的去做。或者更确切地说,您需要选择 J2SE-1.4 执行环境并检查您要在 1.4 合规模式下使用的已安装 JRE 之一;您很可能会安装 1.6 JRE,只需检查一下即可。或者,如果您有安装套件,请安装 1.4 JRE,然后使用该套件。
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.
否则转到您的 Eclipse 首选项,Java -> 编译器并检查合规性是否设置为 1.4。如果是将其更改回 1.6。如果没有转到项目属性,请检查它是否具有项目特定设置。转到 Java Compiler,如果要使用常规 eclipse 首选项,请取消选中。或者将项目特定设置设置为 1.6,这样无论 eclipse 偏好如何,它始终是 1.6。
回答by Pascal Thivent
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).
无论你使用的是maven eclipse插件还是m2eclipse,Eclipse的项目配置都是派生自POM的,所以需要配置maven编译器插件为1.6(默认为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:
将以下内容添加到您的项目中pom.xml
,保存,然后转到您的 Eclipse 项目并选择 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>
回答by Jilles van Gurp
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.
为此,请配置警告面板的内容并确保关闭“构建路径”->“JRE 系统路径问题”类别。此对话框的 UI 有点复杂/奇怪/可用性受到挑战,因此您可能不得不摆弄一些选项以使其执行您想要的操作。
回答by Christian
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.
此警告的实际原因是您已将项目配置为使用较早的 JRE 版本运行,然后再安装。通常,只要您将旧项目与较新的 JRE 一起使用,就会发生这种情况。
This will likely cause no trouble at all.But if you want to be reallyon the save side, you should install the correct, old JDK. You can find them here: http://www.oracle.com/technetwork/java/archive-139210.html
这可能根本不会造成任何麻烦。但是,如果您想真正节省开支,则应该安装正确的旧 JDK。您可以在此处找到它们:http: //www.oracle.com/technetwork/java/archive-139210.html
If you then restart eclipse you can go into Window > Preferences > Java > Installed JREs > Execution Environmentsand set for in your case J2SE-1.4the [perfect match]as eclipse calls it.
如果您然后重新启动 eclipse,您可以进入Window > Preferences > Java > Installed JREs > Execution Environments并在您的情况下为J2SE-1.4设置[perfect match]作为 eclipse 调用它。
回答by N..
If you have Java 1.8 then
如果你有 Java 1.8 那么
You need this xml part in pom.xml and update project.
您需要 pom.xml 中的这个 xml 部分并更新项目。
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
回答by Pragati Chaturvedi
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
我收到了项目警告,因为“构建路径指定了执行环境 J2SE-1.5。工作区中没有安装与此环境严格兼容的 JRE”。我删除了 J2SE1.5 库并添加了新的 JRE 系统库来解决我的问题
回答by Akhil
Expand your project in work space>>Right click(JRE System Libraries)>>select properties>>selectworkspace default JRE the above solution sol
在工作空间中展开您的项目>>右键单击(JRE 系统库)>>选择属性>>选择工作空间默认 JRE 上述解决方案
回答by cyberdemon
the correct procedure to resolve this warning, as other people write, is to go inside your project Propertiesand click on Java Build Pathlocated on the left. Now you will find inside the Libraries Windowthe 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.
正如其他人所写,解决此警告的正确过程是进入您的项目属性并单击位于左侧的Java 构建路径。现在,你会发现里面库窗口的J2SE 1.5在这一个一个新的窗口会给你选择正确的可能性,双击Excecution环境。现在选择您的版本,警告将消失。