JDK仍然在Mac OSX 10.10.2上指向1.6

时间:2015-04-08 13:53:09

标签: java macos jdk1.6

所以我一直在尝试编译我的代码,我收到以下错误:

Information:Using javac 1.7.0_80-ea to compile java sources
Information:java: Errors occurred while compiling module 'DataRegistry'
Information:4/8/15, 9:48 AM - Compilation completed with 14 errors and 0 warnings in 2 sec
    /Users/jvy234/Documents/workspace/dataregistry/src/main/java/com/capitalone/hub/registry/controller/SandboxController.java
    Error:(169, 43) java: diamond operator is not supported in -source 1.6
      (use -source 7 or higher to enable diamond operator)

我手动将CurrentSDK符号链接强制转换为java 1.7:

6003088f811e:~ jvy234$ which java
/usr/bin/java
6003088f811e:~ jvy234$ ls -ltr /usr/bin/java
lrwxr-xr-x  1 root  wheel  74 Jan 21 09:52 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
6003088f811e:~ jvy234$ ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/
total 64
lrwxr-xr-x  1 root  wheel   10 Jan 21 09:52 1.6.0 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 Jan 21 09:52 1.6 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 Jan 21 09:52 1.5.0 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 Jan 21 09:52 1.5 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 Jan 21 09:52 1.4.2 -> CurrentJDK
lrwxr-xr-x  1 root  wheel   10 Jan 21 09:52 1.4 -> CurrentJDK
lrwxr-xr-x  1 root  wheel    1 Jan 21 09:52 Current -> A
drwxr-xr-x  7 root  wheel  238 Jan 21 09:52 A
lrwxr-xr-x  1 root  wheel   59 Apr  8 09:43 CurrentJDK -> /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/

当我转到Java的Preferences面板时,我看到安装了Java 1.7_80。我该怎么做才能使它使用JDK 1.7?

1 个答案:

答案 0 :(得分:0)

您可以更改用于编译项目的{jdk in File/Project Structure/SDKs/Java SDK(参见here)。

如果您希望更改整个工作区的编译器,可以更改File/Settings/Build, Execution, Deployment/Compiler/Java Compiler中使用的编译器(请参阅此doc page)。 如果您仍然收到相同的错误消息,则可以在-source 7选项中传递javac