构建路径指定执行环境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

查看:5009
本文介绍了构建路径指定执行环境J2SE-1.5。工作空间中没有安装与此环境严格兼容的JRE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OS X Yosemite(10.10.2),并且有一些我想在Eclipse中构建的java项目。一些项目很旧,它们都是Java 5,6和7.起初我安装了JDK 7和Eclipse Luna。然后我阅读了

解决方案

我刚刚解决了 - 在项目浏览器中点击Java系统库,并选择属性。在执行环境中刚刚选择了正确的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆