Trying to create a Run configuration in Intellij For a Java application and get a warning that Class not found in module and it doesn't create the Run configuration. This only happened once I added the project to BitBucket. Before that it ran fine.
18 Answers
None of the above worked, I had to do:
File -> Invalidate Caches/ Restart
Upon restart it re-indexed all files and everything worked again as expected.
1The way I fixed the problem was to remove the existing Content Root from the project and adding a new one. For some reason, it looks like it got corrupted.
File->Project Structure under Modules : then on the far right side of the screen where it says Add Content Root, remove the existing Content Root and add it back again pointing to the correct location.
3I'll explain a little bit more detailed version of the Accepted answer.
Open
Project structurewindow (UsingCtrl+Shift+Alt+Sshortkey or FromFile -> Project structureoption in the IDE menu)From there, select
modulestab and remove the current configuration you have.
- Import module again.
- Select the root of your module (The old
.imlfile should be in that folder)
A dialog will popup. Select default options and finish.
Apply the modifications by clicking OK.
My variant: Run -> Edit Configurations -> Configuration -> Environment -> Shorten Command Line Select "JAR Manifest".
i deleted .iml file and reimported the project using maven.
I've struggled with the same problem on my Kotlin project. The solution that works for me:
- Right mouse click on src/main/kotlin/Main.kt
- "Override file type"
- Choose "Kotlin" file type in the "Override file type" menu
- In the "Run/Debug Configuration" set "Main Class" as "MainKt"
set working directory to module root directory or $MODULE_WORKING_DIR$ in Run/Debug configurations settings to help Intellij to find classes.
i had this issue and i found out that the play button on the left side the function is the answer and it solved the error:))
1


