Class not found in module warning when try to create Run/Debug Configuration in Intellij

39,433

Solution 1

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

Solution 2

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.

Solution 3

I'll explain a little bit more detailed version of the Accepted answer.

  1. Open Project structure window (Using Ctrl+Shift+Alt+S shortkey or From File -> Project structure option in the IDE menu)

  2. From there, select modules tab and remove the current configuration you have.

Project structure image

  1. Import module again.

Import module

  1. Select the root of your module (The old .iml file should be in that folder)

Select the right folder

  1. A dialog will popup. Select default options and finish.

  2. Apply the modifications by clicking OK.

Solution 4

i deleted .iml file and reimported the project using maven.

Solution 5

My variant: Run -> Edit Configurations -> Configuration -> Environment -> Shorten Command Line Select "JAR Manifest".

Share:
39,433

Related videos on Youtube

user840930
Author by

user840930

Updated on March 14, 2022

Comments

  • user840930
    user840930 about 2 years

    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.

  • Yogesh Kumar Gupta
    Yogesh Kumar Gupta almost 4 years
    This happened to me while importing a scala maven project, and intellij was dumb to not recognise the App class.
  • Jim Tough
    Jim Tough about 3 years
    This was still a working solution for me on IntelliJ IDEA 2020. I suspect this happened to my run configs after an IntelliJ minor version update.
  • Girdacio Pereira
    Girdacio Pereira about 2 years
    Tks, after deleting .idea from my git repo, the project stopped compilling (of course...), by setting the 'Sources folder' under Modules, it worked again
  • Finn
    Finn almost 2 years
    Thanks. It works for Rider debugging nodejs application too.
  • ha9u63ar
    ha9u63ar almost 2 years
    It doesn't work that way - if you have multiple files, you don't know what you're running