0

enter image description hereI can't run any Java application outside the library folder with IntelliJ IDEA. The error I get is as follows:

Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main

I've tried to update my JDK version but the problem persists. Any suggestions?

P.S. If I run java --version in the terminal, everything is fine.

  • 1
    Does this answer your question? [How do I resolve ClassNotFoundException?](https://stackoverflow.com/questions/17408769/how-do-i-resolve-classnotfoundexception) – OshiniRB Oct 11 '21 at 17:15
  • I think the probelma is indeed with the classpath but I didn't understand how to resolve the issue. – leobartowski Oct 11 '21 at 18:54
  • Show your project structure in IntelliJ IDEA. Is your sources folder marked as sources? – Konstantin Annikov Oct 12 '21 at 04:32
  • Yes, it is. This is my structure, I added the screen to my question. – leobartowski Oct 12 '21 at 15:00
  • Open your Project settings and make sure there's an SDK set for both the project and the module. – duffymo Oct 12 '21 at 15:20
  • Left click on Esercizio in the project tab and press F4 (or go to: File > Project Structure > Modules). On the right, select the src map, and press alt + s (or click 'Sources') so the source map turns blue. If that doesn't work, try closing the project, deleting your .iml and .idea and re-open the project, or just create a new one since you seem to be starting a fresh project anyway. – H3AR7B3A7 Oct 12 '21 at 15:27
  • Guys, thanks for the help! The problem was with the directory, oddly IntelliJ doesn't want '/' in the file name, when I removed it, everything worked perfectly! – leobartowski Nov 12 '21 at 17:56

0 Answers0