Intellij IDEA 使用 java7 编译器编译时我已将其配置

Intellij IDEA using java7 compiler to compile when I have configured it to use Java6(Intellij IDEA 使用 java7 编译器编译时我已将其配置为使用 Java6)

本文介绍了Intellij IDEA 使用 java7 编译器编译时我已将其配置为使用 Java6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Module SDK 设置为 1.6

I have set the Module SDK to 1.6

我还将 Project SDK 设置为 1.6

I have also set the Project SDK to 1.6

我还将 Java 编译器选项从设置更改为使用 java 6

and I also change Java compiler options from setting to use java 6

但它仍然使用 java 7 进行编译.当我编译或运行时,它会出现以下错误

but still it is using java 7 to compile. When I compile or run it gives following error

Using javac 1.7.0_11 to compile java sources
java: Errors occurred while compiling module 'SSLJava6'
Compilation completed with 1 error and 0 warnings in 1 sec
1 error
0 warnings
java: javacTask: source release 1.7 requires target release 1.7

以前有人遇到过这样的问题吗?必须做什么?

Has anyone faced such problem before? What must be done?

java -version的输出

[aniket@localhost jndiProperties]$ java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

我的 JAVA_HOME 也设置为相同.

and my JAVA_HOME is also set to same.

推荐答案

有趣.

问题:

  1. 检查 c:Users$user.IntelliJIdea12configoptionsjdk.table.xml 是否仅引用了 JDK6.

    这就是我的文件的样子:



    如果其中有对 JDK 7 的引用,则删除相应的 <jdk> 元素并重新启动 Intellij.

  2. 我知道您已经确认了javajavac 路径.通过在一个全新的 Intellij 项目中编写一个简单的 HelloWorld.java 来确认正在使用的 javac.

    如果在新项目中使用了 javac6,那么这是旧项目配置的问题.

  3. 如果有公共 JRE 7 潜伏,请尝试暂时卸载它.卸载后检查在 HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment

  4. 处的 Windows 注册表中没有遗留任何内容
  5. 如果重命名JDK7主目录,请检查构建是否失败.如果是这样,请尝试符号链接 JDK7 目录以指向 Java6 安装目录.在 Windows 世界中,以下将用于执行符号链接:mklink/J c:Java7Home c:ExistingJava6Home
  1. Check that c:Users$user.IntelliJIdea12configoptionsjdk.table.xml has a reference to JDK6 only.

    This is what the file looks like for me:



    If there is a reference to a JDK 7 in there then delete the corresponding <jdk> element and restart Intellij.

  2. I know that you have confirmed the java and javac path. Confirm the javac being used by writing a simple HelloWorld.java in a brand new Intellij project.

    If in the new project javac6 is used, then it's an issue with the old project configuration.

  3. If there is a public JRE 7 lurking about, try un-installing it temporarily. After un-installation check that there is no cruft left behind in the Windows registry at HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment

  4. Check whether the build fails if you rename the JDK7 home dir. If so, try symlinking the JDK7 dir to point to the Java6 installation dir. In the windows world the following will work to do the symlink : mklink /J c:Java7Home c:ExistingJava6Home

这篇关于Intellij IDEA 使用 java7 编译器编译时我已将其配置为使用 Java6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Intellij IDEA 使用 java7 编译器编译时我已将其配置

基础教程推荐