构建路径指定执行环境 J2SE-1.5.工作空间中没有安装与此环境严格兼容的 JRE [英] Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment
问题描述
我使用 OS X Yosemite (10.10.2) 并且有一些我想在 Eclipse 中构建的 Java 项目.有些项目是旧的,它们是 Java 5、6 和 7.起初,我安装了 JDK 7 和 Eclipse Luna.然后我读了 有此问题的博客文章和解决方案是
<块引用>...用其他人 Mac 上的文件替换A"子目录
但我不知道有人在优胜美地使用这些 Java 版本.
我尝试在 Eclipse 首选项中更改执行环境
但这没有帮助.
项目属性中的Java Build Path 是J2SE-1.5,我尝试通过备用JRE 更改执行环境>
但是当我保存这个设置并再次打开它时J2SE-1.5仍然是执行环境(J2SE-1.5)
然后我尝试在 build.xml
source
和 target
但它没有帮助.
您知道如何在优胜美地的 Eclipse 中使用 Java 5 构建项目吗?
//问题是 JDK 1.5 路径指的是 CurrentJDK,什么是 JDK 1.6.我再次运行 JDK 1.5 和 1.6 的安装,现在 JDK 1.5 与 JDK 1.5 链接
lrwxr-xr-x 1 根轮 10 8 apr 14:36 1.4 ->当前JDKlrwxr-xr-x 1 根轮 10 8 apr 14:36 1.4.2 ->当前JDKlrwxr-xr-x 1 根轮 10 9 apr 11:01 1.5 ->./1.5.0_30lrwxr-xr-x 1 根轮 10 9 apr 11:01 1.5.0 ->./1.5.0_30drwxr-xr-x 9 根轮 306 4 月 9 日 11:01 1.5.0_30lrwxr-xr-x 1 根轮 10 8 apr 14:36 1.6 ->当前JDKlrwxr-xr-x 1 根轮 10 8 apr 14:36 1.6.0 ->当前JDKdrwxr-xr-x 7 根轮 238 4 月 8 日 14:36 Alrwxr-xr-x 1 根轮 1 4 月 8 日 14:36 当前 ->一种
在项目属性中,我没有收到任何编译器警告,但显然 JDK 1.5 没有 JRE 1.5,因为如果我打开 Eclipse 首选项 Java->Installed JREs->Execution Environments,则没有任何 JRE 1.5
而且我无法在 Java 5 中构建项目,因为出现错误:
Build path 指定执行环境 J2SE-1.5.工作空间中没有安装与此环境严格兼容的 JRE.
这是/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
目录的内容
我决定打开新的线程
我通过在 Project Explorer 中右键单击Java System Library"并选择Properties"解决了我的问题.在执行环境"中选择了正确的Java版本.
I use OS X Yosemite (10.10.2) and have some java projects which I want to build in Eclipse. Some projects are old and they are in Java 5, 6 and 7. At first, I installed JDK 7 and Eclipse Luna. Then I read this and this thread how to install specific JDK on mac. I used this script to install JDKs and changed these two lines in order to Yosemite compatibility.
/usr/libexec/PlistBuddy -c "Set :JavaVM:JVMMaximumFrameworkVersion 14.*.*" ./Resources/Info.plist
/usr/libexec/PlistBuddy -c "Set :JavaVM:JVMMaximumSystemVersion "$osx_version".*" ./Resources/Info.plist
by
/usr/libexec/PlistBuddy -c "Delete :JavaVM:JVMMaximumFrameworkVersion" ./Resources/Info.plist
/usr/libexec/PlistBuddy -c "Delete :JavaVM:JVMMaximumSystemVersion" ./Resources/Info.plist
Here is content of my /System/Library/Frameworks/JavaVM.framework/Versions
directory
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.5.0 -> CurrentJDK
drwxr-xr-x 9 root wheel 306 8 apr 14:32 1.5.0_30
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.6.0 -> CurrentJDK
drwxr-xr-x 7 root wheel 238 8 apr 14:36 A
lrwxr-xr-x 1 root wheel 1 8 apr 14:36 Current -> A
lrwxr-xr-x 1 root wheel 59 8 apr 14:36 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
Location of JDK 7 is different and the path is /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk
Default Java version is:
AND:bin andr-work$ java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
Here are installed JDKs in Eclipse preferences
Version 7
Version 6
Version 5
When I want to build projects in java 6 or 7, I don't have any problems with java compiler in Eclipse
But I cannot build some projects in java 5 and probably compiler for java 5 is not set properly
I found this blog post with this problem and solution is
...replace the "A" subdirectory with files from someone else's Mac
but I don't know anybody with working these java versions in Yosemite.
I tried to change Execution Environments in Eclipse preferences
But it didn't help.
Java Build Path in project properties is J2SE-1.5 and I tried to change Execution environment by Alternate JRE
but when I save this settings and open it again J2SE-1.5 is still Execution environment (J2SE-1.5)
Then I tried to add java source
and target
in build.xml
<?xml version="1.0"?>
<project name="build" default="jar">
<description>
A build script
</description>
<property name="ant.build.javac.source" value="1.5"/>
<property name="ant.build.javac.target" value="1.5"/>
<property name="dist.jar" value="ci-ons.jar"></property>
<property name="dist.folder" value="dist"></property>
<property name="src.folder" value="src"/>
<property name="classes.folder" value="bin"/>
</project>
but it didn't help.
Do you have any idea how can i build projects in java 5 in Eclipse in Yosemite?
EDIT:// The problem was JDK 1.5 path referred to CurrentJDK, what was JDK 1.6. I run installation of JDK 1.5 and 1.6 again and now JDK 1.5 is linked with JDK 1.5
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 9 apr 11:01 1.5 -> ./1.5.0_30
lrwxr-xr-x 1 root wheel 10 9 apr 11:01 1.5.0 -> ./1.5.0_30
drwxr-xr-x 9 root wheel 306 9 apr 11:01 1.5.0_30
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 apr 14:36 1.6.0 -> CurrentJDK
drwxr-xr-x 7 root wheel 238 8 apr 14:36 A
lrwxr-xr-x 1 root wheel 1 8 apr 14:36 Current -> A
In project properties I don't get any warnings of compiler, but apparently JDK 1.5 doesn't have JRE 1.5, because if I open Eclipse preferences Java->Installed JREs->Execution Environments, there is not any JRE 1.5
and I cannot build projects in Java 5, because I get errors:
Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
This is content of /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
directory
I decided to open new thread
I solved mine with just right-clicking the "Java System Library" in the Project Explorer and chose "Properties". In the "Execution environment" just selected the right Java version.
这篇关于构建路径指定执行环境 J2SE-1.5.工作空间中没有安装与此环境严格兼容的 JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!