---
title: "Intellij IDEA 使用 java7 compiler to compile 转为java6"
author: "goahead2010"
date: "2014-10-13T15:55:23Z"
tags: []
categories: ["编程语言"]
slug: "intellij-idea-java7-compiler-to-compile-java6"
draft: false
lastmod: "2014-10-13T16:06:57Z"
id: 2135333
url: "https://goahead2010.iteye.com/blog/2135333"
---

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编译的了**

 

0[down vote]()[favorite](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j "This is a favorite question (click again to undo)")

 

I have set the Module SDK to 1.6

![](http://dl2.iteye.com/upload/attachment/0101/9250/91d94ef0-0354-353f-af8a-ff8173ff4086.png)  
 

I have also set the Project SDK to 1.6

![](http://dl2.iteye.com/upload/attachment/0101/9254/3fcb99f3-17f2-324e-9a06-0d17f640e3d4.png)  
 

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

![](http://dl2.iteye.com/upload/attachment/0101/9248/253690c8-ed70-373f-bcbe-49f1911e5059.png)  
 

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

```java
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`

```java
[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.

[java](http://stackoverflow.com/questions/tagged/java "show questions tagged 'java'") [sdk](http://stackoverflow.com/questions/tagged/sdk "show questions tagged 'sdk'") [intellij-idea](http://stackoverflow.com/questions/tagged/intellij-idea "show questions tagged 'intellij-idea'")

[share](http://stackoverflow.com/q/18756469 "short permalink to this question")|[improve this question](http://stackoverflow.com/posts/18756469/edit)

asked Sep 12 '13 at 6:02

![](http://i.stack.imgur.com/ZUwcx.png?s=32&g=1)

[Aniket Thakur](http://stackoverflow.com/users/2396539/aniket-thakur)  
11.3k33265

 

    

What does `javac -version` show? And are you using maven to build? –  [maba](http://stackoverflow.com/users/1350762/maba "15425 reputation") [Sep 12 '13 at 6:13](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j#comment27648561_18756469)

    

javac -version shows also shows javac 1.6.0\_30 and no I am not using maven. –  [Aniket Thakur](http://stackoverflow.com/users/2396539/aniket-thakur "11309 reputation") [Sep 12 '13 at 6:35](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j#comment27649158_18756469)

    

Which version of IntelliJ? 12.1.4 ? –  [vikingsteve](http://stackoverflow.com/users/1993366/vikingsteve "7070 reputation") [Sep 12 '13 at 8:07](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j#comment27652047_18756469) 

    

Maybe you also have some dependencies set on SSLJava6? –  [gorex](http://stackoverflow.com/users/1168235/gorex "66 reputation") [Sep 12 '13 at 8:40](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j#comment27653022_18756469)

    

@vikingsteve yes it's 12.1.4 –  [Aniket Thakur](http://stackoverflow.com/users/2396539/aniket-thakur "11309 reputation") [Sep 12 '13 at 8:59](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j#comment27653649_18756469)

[show **3** more comments](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j "expand to show all comments on this post, or add one of your own")

[]()

## 1 Answer

[active](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j?answertab=active#tab-top "Answers with the latest activity first")[oldest](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j?answertab=oldest#tab-top "Answers in the order they were provided")[votes](http://stackoverflow.com/questions/18756469/intellij-idea-using-java7-compiler-to-compile-when-i-have-configured-it-to-use-j?answertab=votes#tab-top "Answers with the highest score first")

[]()

[up vote]()1[down vote]()

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:
   
   ![](http://dl2.iteye.com/upload/attachment/0101/9252/f067328b-d959-39fe-a9ce-c3857ea5b9bc.png)  
    
   
   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`

[share](http://stackoverflow.com/a/18802319 "short permalink to this answer")|[improve this answer](http://stackoverflow.com/posts/18802319/edit)

an