parsecer
parsecer

Reputation: 5176

Intellij IDEA doesn't recognize java file: blue square in directory

I have a project structure like this:

enter image description here

src (sources root)
---main  
-------java (sources root)
-----------com
--------------requests
----------------------File1.java (needs to be package com.requests)
----------------------File2.java (needs to be package com.requests)
----------------------File3.java (needs to be package com.requests)
--------------things
--------------util
--------------web
-------resources
----------------images
-------webapp
-------------WEB-INF
--------------------classes
---------------------------com
------------------------------requests
------------------------------things
------------------------------util
------------------------------web
---------------------lib

However, File1.java, File2.java and File3.java don't seem to be recognized as Java files and I can't compile them:

enter image description here

Why? How do I fix it?

Upvotes: 5

Views: 3989

Answers (1)

Karol Dowbecki
Karol Dowbecki

Reputation: 44980

You should unmark src directory as a source root because it doesn't contain Java code. In your example only src/main/java directory should be marked as source root.

You can do it by right clicking on src and selecting "Mark Directory as" > "Unmark as Source Root".

Upvotes: 8

Related Questions