从JDK 1.6切换到1.7后,Intellij Idea不会编译我的项目

时间:2023-01-17 12:10:55

I created an Intellij project under JDK 1.6. Then I installed JDK 1.7 and removed JDK 1.6.

我在JDK 1.6下创建了一个Intellij项目。然后我安装了JDK 1.7并删除了JDK 1.6。

When I opened the project, I changed JDK to 1.7 in the Project structure dialog.

当我打开项目时,我在项目结构对话框中将JDK更改为1.7。

从JDK 1.6切换到1.7后,Intellij Idea不会编译我的项目

But my files are not recompiled - if I add errors into my code and select Build -> Rebuild project, no compiler errors appear.

但我的文件没有重新编译 - 如果我在代码中添加错误并选择Build - > Rebuild project,则不会出现编译器错误。

I also tried File -> Invalidate caches without any result.

我还尝试了File - > Invalidate caches而没有任何结果。

How can I enable compilation of my source code again?

如何再次启用源代码编译?

I'm using IntelliJ IDEA 12.1.4 Ultimate.

我正在使用IntelliJ IDEA 12.1.4 Ultimate。

Update 1 (23.09.2013 18:48 MSK): I forgot to mention that all Java files appear with a small red J near them.

更新1(2013年9月23日18:48 MSK):我忘了提到所有Java文件都附近有一个小的红色J。

从JDK 1.6切换到1.7后,Intellij Idea不会编译我的项目

3 个解决方案

#1


3  

The reason for this strange behaviour was that there was a nested Intellij project inside the one I opened. When I opened the child project, the compilation started to work.

这种奇怪行为的原因是我打开的那个内部有一个嵌套的Intellij项目。当我打开子项目时,编译开始工作。

#2


2  

I had to go to Project Settings > Modules and set the Source directory so intellij would know where to look. Thank you, @maba, for that comment

我必须转到项目设置>模块并设置源目录,以便intellij知道在哪里查看。感谢@maba,感谢您的评论

#3


0  

Wipe out the files in your compiler output directory (usually projectdir/out). IntelliJ only compiles changed files and the files themselves haven't changed, so you'll need to wipe out the .class files compiled under the previous JDK.

擦除编译器输出目录中的文件(通常是projectdir / out)。 IntelliJ只编译已更改的文件,文件本身没有更改,因此您需要清除在以前的JDK下编译的.class文件。

#1


3  

The reason for this strange behaviour was that there was a nested Intellij project inside the one I opened. When I opened the child project, the compilation started to work.

这种奇怪行为的原因是我打开的那个内部有一个嵌套的Intellij项目。当我打开子项目时,编译开始工作。

#2


2  

I had to go to Project Settings > Modules and set the Source directory so intellij would know where to look. Thank you, @maba, for that comment

我必须转到项目设置>模块并设置源目录,以便intellij知道在哪里查看。感谢@maba,感谢您的评论

#3


0  

Wipe out the files in your compiler output directory (usually projectdir/out). IntelliJ only compiles changed files and the files themselves haven't changed, so you'll need to wipe out the .class files compiled under the previous JDK.

擦除编译器输出目录中的文件(通常是projectdir / out)。 IntelliJ只编译已更改的文件,文件本身没有更改,因此您需要清除在以前的JDK下编译的.class文件。