本文介紹了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.
推薦答案
有趣.
問題:
- 檢查
c:Users$user.IntelliJIdea12configoptionsjdk.table.xml
是否僅引用了 JDK6.
這就是我的文件的樣子:
如果其中有對 JDK 7 的引用,則刪除相應的<jdk>
元素并重新啟動 Intellij. - 我知道您已經確認了
java
和javac
路徑.通過在一個全新的 Intellij 項目中編寫一個簡單的 HelloWorld.java 來確認正在使用的 javac.
如果在新項目中使用了 javac6,那么這是舊項目配置的問題. - 如果有公共 JRE 7 潛伏,請嘗試暫時卸載它.卸載后檢查在
HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment
處的 Windows 注冊表中沒有遺留任何內容 - 如果重命名JDK7主目錄,請檢查構建是否失敗.如果是這樣,請嘗試符號鏈接 JDK7 目錄以指向 Java6 安裝目錄.在 Windows 世界中,以下將用于執行符號鏈接:
mklink/J c:Java7Home c:ExistingJava6Home
- 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. - I know that you have confirmed the
java
andjavac
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. - 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
- 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!