Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ on Mac Can't detect syntax errors for JAVA

I just started using IntelliJ on Mac. The problem I met is that syntax error on my java file can't be detected and highlighted as in PC.

The problem is errors are not detected instead of errors not being highlighted, because I have checked the highlighting setting.

Any configuration I can play with to let the syntax error can be detected?

i.e.,

test = "Test"; There is no class declaration.

like image 414
user1470393 Avatar asked Mar 20 '14 20:03

user1470393


1 Answers

I'm going to guess that your Java classes have this icon when you open them:

enter image description here

What this means is that your Java class file isn't in a recognized source root. IntelliJ doesn't know that this is a source file, so it won't treat it as one.

Right-click on the folder, and select "Mark Directory As" -> "Sources Root".

enter image description here

After that, drag and drop your Java class into that folder. Then, you'll see it appear as this:

enter image description here

Then IntelliJ will report all of your errors.

like image 91
Makoto Avatar answered Oct 22 '22 13:10

Makoto