欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Intellij IDEA 使用 java7 compiler to compile 转为java6 博客分类: Intellij IDEA  

程序员文章站 2024-03-14 12:07:40
...

http://*.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


Intellij IDEA 使用 java7 compiler to compile 转为java6
            
    
    博客分类: Intellij IDEA  
 

I have also set the Project SDK to 1.6


Intellij IDEA 使用 java7 compiler to compile 转为java6
            
    
    博客分类: Intellij IDEA  
 

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


Intellij IDEA 使用 java7 compiler to compile 转为java6
            
    
    博客分类: Intellij IDEA  
 

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

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:


    Intellij IDEA 使用 java7 compiler to compile 转为java6
            
    
    博客分类: Intellij IDEA  
     

    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