Intellij IDEA 使用 java7 compiler to compile 转为java6

本文解决了一个关于IntelliJ IDEA配置使用Java6进行编译的问题,即便已将模块和项目的JDK设置为1.6,仍然错误地使用Java7进行编译。文章提供了详细的排查步骤,包括检查配置文件、确认编译器路径及版本等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j

我用了两个jdk,现在只保留jdk6就可以了,或者建一个新project,新的project就是用java6编译的了

 

I have set the Module SDK to 1.6



 

I have also set the Project SDK to 1.6



 

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



 

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?

Output of java -version

[aniket@localhost jndiProperties]$ java -version
java version "1.6.0_30"Java(TM) SE RuntimeEnvironment(build 1.6.0_30-b12)JavaHotSpot(TM)64-BitServer VM (build 20.5-b03, mixed mode)

and my JAVA_HOME is also set to same.

share | improve this question
 
   
What does javac -version show? And are you using maven to build? –   maba  Sep 12 '13 at 6:13
   
javac -version shows also shows javac 1.6.0_30 and no I am not using maven. –   Aniket Thakur  Sep 12 '13 at 6:35
   
Which version of IntelliJ? 12.1.4 ? –   vikingsteve  Sep 12 '13 at 8:07 
   
Maybe you also have some dependencies set on SSLJava6? –   gorex  Sep 12 '13 at 8:40
   
@vikingsteve yes it's 12.1.4 –   Aniket Thakur  Sep 12 '13 at 8:59

1 Answer

Interesting.

Questions:

  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 atHKEY_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
share | improve this answer
### 解决 Intellij IDEA Java Spring Boot 项目编译错误 “找不到符号” 在处理IntelliJ IDEA中运行Java Spring Boot项目时遇到的“找不到符号”的编译错误,通常这类问题是由于某些类文件未能正确编译至`target`目录所引起[^1]。当多个地方报告相同的错误提示,并且确认源码本身无误,则应考虑构建过程中的配置问题。 #### 验证项目结构 确保项目的模块路径和依赖关系已正确定义于`pom.xml`或`build.gradle`文件内。对于Maven项目而言,任何外部库都应当通过相应的坐标声明并由Maven统一管理版本号以及下载安装到本地仓库中。 #### 清理与重新构建工程 尝试执行清理操作来移除旧有的编译产物: ```bash mvn clean install -U ``` 上述命令不仅会清除现有的目标文件夹(`target`)内的内容,还会强制更新所有过期的依赖项。这有助于排除因缓存残留而引发的一系列潜在冲突。 #### 启用自动Make功能 为了防止手动触发Build动作带来的不便,在IDEA里可以开启自动编译选项。前往菜单栏选择 `File -> Settings (Ctrl+Alt+S)` ,导航至 `Build, Execution, Deployment -> Compiler` 下勾选 `Compile independent modules in parallel` 和 `Use '--incremental' compilation option for Make` 。此外还需检查 `Build project automatically` 是否处于激活状态[^3]。 #### 检查Module SDK配置 有时开发环境可能选择了不合适的SDK版本作为默认解释器,从而影响到了字节码生成环节。进入 `Project Structure (Ctrl+Alt+Shift+S)` 查看当前使用的JDK是否匹配Spring Boot应用的需求规格说明文档里的建议值。 #### 更新插件和支持包 保持工具链组件始终处在最新稳定版能够有效减少兼容性隐患的发生几率。特别是像Lombok这样的第三方增强型框架更需注意其迭代进度,及时同步对应的处理器程序以保障注解解析机制正常运作。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值