Java file outside of source root intellij idea что делать
If you do an ‘import from git’, IntelliJ doesn’t import the project structure from maven (or gradle) automatically.
One way to do this afterwards is to right-click on the pom.xml file in the root directory, and select ‘Add as maven project’. Then the folders will be marked correctly, and dependent libraries will be imported. There should be no need to mark individual source folders manually.
I prefer to do a git clone outside of IntelliJ, and open the project from the local filesystem, then IntelliJ imports the maven project structure automatically.
This has been driving me quite mad and I am a newbie as well. I finally solved it by using:
file > project structure >
Then going to Modules and removing all the files from the root using the x marks on the far right. I then used the +Add Content Root to reselect the src folders that contained my .java and hit Apply. Finally InteliJ sees the files as in the project and the folders gain the blue square on the main view.
Very simple solution :-
Click on «maven» on the right toolbar in IntelliJ and then click on the refresh button.
Java file outside of source root intellij idea что делать
** Error: (vlog-13069) ** while parsing file included at ./pcie_cpl_pkg.sv(9) ** at pcie_cpl_pins.sv(35): near “pcie_cpl_pins”: syntax.
IDEA error Error: java: Invalid source distribution: 10
Using IDEA to report an error The following error occurred when using the idea to create a new module. The following error occurred when using the idea to create a new module. The final discovery is t.
Java file outside of source root about a-file-icon-idea HOT 2 OPEN

Describe the bug
After updated to version 64.0.0 it started to show what i thinks is the default icon for what an icon is missing. When hovering the icon it shows a label with the text «Java file outside of source root»
To Reproduce

- Create a Java project using intelliJ
- Look at any .java file icon.

Expected Behavior
Show the correct Java icon for .java files.
Environment
IntelliJ IDEA 2022.1 (Ultimate Edition)
Build #IU-221.5080.210, built on April 11, 2022
Runtime version: 11.0.14.1+1-b2043.25 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.3.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry:
ide.intellij.laf.enable.animation=true
ide.balloon.shadow.size=0
ide.images.show.chessboard=true
Non-Bundled Plugins:
com.mallowigi.idea (17.0)
com.github.copilot (1.1.17.1262)
org.asciidoctor.intellij.asciidoc (0.37.17)
org.sonarlint.idea (6.7.0.45926)
mobi.hsz.idea.gitignore (4.4.0)
com.mallowigi (64.0.0)
dev.flikas.idea.spring.boot.assistant.plugin (0.2.4)
intellij.prettierJS (221.5080.169)
izhangzhihao.rainbow.brackets (6.22)
io.jmix.studio (1.2.1-213)
com.haulmont.jpab (2022.2.2-221)
Screenshots
Error

Expected

Comments (2)
Thanks for opening your first issue here! Be sure to follow the issue template!
stale commented on May 15, 2022
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Related Issues (20)
- «External Libraries» icons are broken HOT 8
- Icons are not loaded if UI Icons is off (at start) HOT 55
- Some icons not rendering in WebStorm 2022.1 HOT 2
- IDE icons disappear in v61 HOT 1
- Update plugin without restart IDEA HOT 2
- Folder Icon doesn’t work on Rider HOT 1
- Atom Material Icons exception HOT 6
- Pycharm 2022 deployment icon missing. HOT 2
- Unable to see which files/folders are symlinks HOT 2
- Vertical padding in custom icon size HOT 5
- Support PyCharm 2022.2 EAP HOT 1
- Support Webstorm EAP 2022.2 HOT 2
- Incompatible with IntelliJ Version 2022.2 EAP Build #IC-222.2680.4 HOT 2
- Any prediction when this will be compatible with latest Rider EAP 2022.2 EAP1? HOT 2
- Custom folder icons for open state
- Disabling UI icons disables the PSI icons checkbox
- Add new icons set from Material Design 2/3 (Outlined, Dual tone, Round, . ) HOT 2
- Add icon to custom button HOT 3
- Why some folders has filling and some not? HOT 2
Recommend Projects
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
Vue.js
Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
TensorFlow
An Open Source Machine Learning Framework for Everyone
Django
The Web framework for perfectionists with deadlines.
Laravel
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML.
Recommend Topics
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
server
A server is a program made to process requests and deliver data to clients.
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Visualization
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
Recommend Org
We are working to build community through open source technology. NB: members must have two-factor auth.
[Solution] IntelliJ: Cannot find declaration to go to, Nothing here, Java file outside of source root Errors
If you are trying to access a class and its member variables and methods in IntelliJ IDE for an external dependency (be it Maven or Gradle) you may see a tooltip saying "Cannot find declaration to go to" if the source of the class is not available.
If you hover over your class if you see "Java file outside of source root" and when you try to run the main method you would not be able to run the application with a message "Nothing here"
Open installed Plugins (press Shift key twice) and disable Gradle and restart IntelliJ, you will be prompted to enable Gradle, once dependencies and their source are downloaded and the build is complete, this error should be fixed.

report this ad
Java file outside of source root intelliJ
I have cloned a spring boot project from GitLab having multiple branches in IntelliJ. I checkout to the branch in which I want to work. But I am getting "Java file outside of source root" on all the files. Please suggest what I am doing wrong. I just installed IntelliJ and it’s the first project that I am importing.
27 Answers 27
If you do an ‘import from git’, IntelliJ doesn’t import the project structure from maven (or gradle) automatically.
One way to do this afterwards is to right-click on the pom.xml file in the root directory, and select ‘Add as maven project’. Then the folders will be marked correctly, and dependent libraries will be imported. There should be no need to mark individual source folders manually.
I prefer to do a git clone outside of IntelliJ, and afterwards open the project in IntelliJ from the local filesystem, then IntelliJ imports the maven project structure automatically.
![]()
Very simple solution: —
Click on "maven" on the right toolbar in IntelliJ and then click on the refresh button.
![]()
I fixed it using this way:
and then marked java files dir as Sources.
This has been driving me quite mad and I am a newbie as well. I finally solved it by using:
file > project structure >
Then going to Modules and removing all the files from the root using the x marks on the far right. I then used the +Add Content Root to reselect the src folders that contained my .java and hit Apply. Finally InteliJ sees the files as in the project and the folders gain the blue square on the main view.
[Solved]-Java file outside of source root intelliJ-Springboot
If you do an 'import from git', IntelliJ doesn't import the project structure from maven (or gradle) automatically.
One way to do this afterwards is to right-click on the pom.xml file in the root directory, and select 'Add as maven project'. Then the folders will be marked correctly, and dependent libraries will be imported. There should be no need to mark individual source folders manually.
I prefer to do a git clone outside of IntelliJ, and afterwards open the project in IntelliJ from the local filesystem, then IntelliJ imports the maven project structure automatically.
GeertPt 14568
I'm just gonna throw my solution to this problem in here, since none of the above worked:
If there are multiple pom files in your project, on the Maven sidebar to the right, click the plus ('+') button and navigate to the other pom file that does not have the Maven ('M') icon next to it in the project structure of your project (left sidebar).
Then click 'OK' — this then loads all the Maven dependencies from the unused pom file and, for me, everything was finally fixed!
Maven sidebar > plus icon (+) > direct to other pom file > 'ok'
I had to open the module I worked on to a new window to solve that.
Anwar Benhamada 191
Hate to add yet another method; but this one worked for me after trying and failing with the above methods. I had a multi-mode project. Unlinked all maven projects in Maven workspace and reloaded as maven project by clicking root poom.xml in project workspace. Not sure whether this will always work and for everyone.
IntelliJ may be ignoring files from a multi-module project. Modules that are ignored will make it harder for the IDE to find the root of that file. Hence, java file outside of source root
Now, uncheck the modules you do not want IntelliJ to ignore.
chris 1839
I faced the same problem in one of the modules in my multi module maven project. In my InteliJ idea, I've installed Maven Helper plugin before. I did right click on the module and within that contextual menu click Run Maven and then Reimport. After doing that, my issue resolved.
Select root pom.xml —> Click Maven — Unlink <— This will remove all sub modules
Select root pom.xml —> Add As Maven project
Then everythings worked..
JCompetence 4429
I did a 'Maven reload' (or Gradle reload) from the upper-right 'Maven' ('Gradle') window and problem is solved.
File -> Project Structure -> Module select the Sources tab in the third pane from the left
Resolved !! Go to your project on IntelliJ -> Right click on pom.xml -> Add as Maven Project.
Regenerate Maven Sources and Update Folders
When moving the project from one directory to another, Maven will need to regenerate the sources to tell the project to use Annotation Processing.
Try this
Right click the pom.xml > Maven > Generate Sources and Update Folders
The project should now run
Here's an image of what the menu looks like for me, in May 2022, as the answers have seemed to vary over time:

Quan Truong 124
I'm having a similar issue for an Android project in Android Studio Chipmunk 2021.2.1 Patch 1. It looks like a known bug related to using manifest.srcFile : https://issuetracker.google.com/issues/218370114?hl=ko
Apparently the options are switching to the canary channel or waiting for the fix to be released on the stable channel. Or getting rid of manifest.srcFile in your build.gradle .
In intellij: click Maven, select the project and right, select Unignore Projects
For ppl like me who also see that the POM file is crossed out and greyed(ignored):
You can right click the POM.xml, select "Maven — Unignore projects".
WesternGun 9340
Right click on pom.xm >> maven >> Reload project
Diego Virgüez 135
To Solve: "Java file outside of source root"
- Open Project Structure.
- Select Modules in Project Settings in left pane.
- Click on the folder in which your Java files (showing file outside of source root) are present.
- Then Select Sources from Mark as: option.
- Apply the same steps for multiple folders.

razorblack 121
This has been driving me quite mad and I am a newbie as well. I finally solved it by using:
file > project structure >
Then going to Modules and removing all the files from the root using the x marks on the far right. I then used the +Add Content Root to reselect the src folders that contained my .java and hit Apply. Finally InteliJ sees the files as in the project and the folders gain the blue square on the main view.
SlinnShady 325
I fixed it using this way:
and then marked java files dir as Sources.
Very simple solution :-
Click on "maven" on the right toolbar in IntelliJ and then click on the refresh button.