Error: Could not find or load main class Main in Intellij IDE



I'm new to Java and today I was trying to create a simple "HelloWorld" project in IntelliJ. Unfortunatelly when I try to run a project I got this error: Error: Could not find or load main class
Caused by: java.lang.ClassNotFoundException:

Here is a screen:

I search in stackoverflow and intelij support forum. Change and add path, but nothing work for me.

When I try to compile a program from CMD everything is working fine. Could someone help me with it? It seems like some configuration problem in Intelij, but I cann't understand how to fix it.



Could you please check that compiled class is present in "out " folder. Is it possible to attach full classpath from the output?


Hello Yaroslav,

thank you for response.

Here is a screenshot from the "out" folder:

Classpath is:

And in project structure:



Sorry, I meant full classpath/command from Run tool window output. Also, could you please try to check the issue with new project without space in project name?


Hi Yaroslav Bedrov,

having the same problem since IntelliJ 2022.3.x
(works perfectly with 2022.2.x or earlier)

May have something to do with the packaging change around the Main class

Here my run command:

"C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\jbr\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=,suspend=y,server=n -Xmx1024m -Xms256m -XX:MaxPermSize=250m -ea -Dplugin.classloader.debug=true -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.config.path=D:\data\IntelliJIdea23.1\system\plugins-sandbox\config -Didea.system.path=D:\data\IntelliJIdea23.1\system\plugins-sandbox\system -Didea.plugins.path=D:\data\IntelliJIdea23.1\system\plugins-sandbox\plugins -Didea.classpath.index.enabled=false -Djdk.module.illegalAccess.silent=true --add-opens=java.base/ --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/ --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.vm=ALL-UNNAMED --add-opens=java.base/ --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.base/ --add-opens=java.base/ --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.desktop/ --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.swing=ALL-UNNAMED --add-opens=jdk.attach/ --add-opens=jdk.compiler/ --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=jdk.jdi/ -Didea.platform.prefix=Idea -javaagent:D:\data\IntelliJIdea22.3\system\captureAgent\debugger-agent.jar=file:/C:/Users/CiocaD/AppData/Local/Temp/1/capture.props -Dfile.encoding=windows-1252 -classpath "D:\data\IntelliJIdea22.3\system\captureAgent\debugger-agent.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\log4j.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\jdom.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\trove4j.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\openapi.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\util.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\util_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\bootstrap.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\idea.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\3rd-party-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 23.1 CE\lib\jna.jar;C:\Program Files\JetBrains\IntelliJ IDEA 22.3\lib\idea_rt.jar" com.intellij.idea.Main



Actually my problem is with a DevKit plugin run configuration. I may be in the wrong thread here... 


Same here. No longer working.


Do you also have simple "Hello World" application?


Yaroslav Bedrov

After having wasted +8 hours dealing with this today I don't feel I have any time or energy to repeat this tomorrow. It might not be straightforward to reproduce as structure might be part of it as Afrina mentioned here:

I reported the issue here:

And commented on many similar tickets, whereby this appears to be known:

Suggested patch but has not tried or read it:

I do not use gradle or kotlin for plugin development, and I have my reasons for that, which are valid and good. 

If you want to see what is happening we can scheduele a timeslot and I can screenshare, other than that, my plugin development happened today, change by change, rebuilding, zipping manually, getting into issues, manually installing zip file while trying to get this to work as it used to. 

Can not put more time into this at this time. Hope you fix this issue til next time. 

I doubt any deployment relying on the old devkit actually works currently as the runtime args seems to be completely off. See the ticket I filed. 


I had a similar problem with a new (maven) project that I created with IntelliJ. The solution was to restart IntelliJ and do a maven->clean