Cannot run Main class in Intellij [duplicate]

烈酒焚心 提交于 2021-01-27 04:28:09

问题


I have the following project structure

-ProjectRoot
---src
------Main
------examples
---libs

My src folder is marked as sources in Intellij.

Now, when I want to run Main class, I get the following error:

Exception in thread "main" java.lang.ClassNotFoundException: Main

Any ideas on what am I doing wrong?

Here is my main class:

public class Main {
    public static void main(String[] args) {
        System.out.println("hello world");
      }
    }

It doesn't have any package statements.


回答1:


Clean the project, edit run configuration, choose the main class manually again. This probably wouldn't be needed if you had src/main/java structure.



来源:https://stackoverflow.com/questions/40068285/cannot-run-main-class-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!