当我将其配置为使用Java6时,使用java7编译器进行Intellij IDEA编译 [英] Intellij IDEA using java7 compiler to compile when I have configured it to use Java6

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

问题描述

我已将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也设置为相同.

推荐答案

有趣.

问题:

  1. 检查c:\Users\$user\.IntelliJIdea12\config\options\jdk.table.xml仅具有对JDK6的引用.

    这是文件的外观:



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

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

    如果在新项目中使用javac6,则旧项目配置存在问题.

  3. 如果有一个公开的JRE 7,请尝试暂时将其卸载.卸载后,请检查Windows注册表中是否没有残留文件,该文件位于HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

  4. 如果重命名JDK7主目录,请检查构建是否失败.如果是这样,请尝试符号链接JDK7目录以指向Java6安装目录.在Windows世界中,以下将进行符号链接:mklink /J c:\Java7Home c:\ExistingJava6Home
  1. Check that c:\Users\$user\.IntelliJIdea12\config\options\jdk.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_MACHINE\SOFTWARE\JavaSoft\Java 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

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

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