Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 611
parsecer Avatar asked Feb 14 '19 17:02

parsecer


People also ask

What does Blue Square on folder mean Intellij?

It means the folder is defined as an Intellij Module. Complete list of Intellij icons: https://www.jetbrains.com/idea/help/symbols.html. Follow this answer to receive notifications. edited Mar 15, 2018 at 13:20.

Why I Cannot run java file in Intellij?

Be sure that you have the module for the project set to the Java JDK. Otherwise, try putting a break point on the only executable line in the code and enter debug mode.

Why are my java files orange Intellij?

It means those files aren't part of the project settings. Show activity on this post. mark the java folder as source root.It will solve.


Video Answer


1 Answers

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".

like image 107
Karol Dowbecki Avatar answered Oct 21 '22 13:10

Karol Dowbecki