Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run Main class in Intellij [duplicate]

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.

like image 909
uksz Avatar asked Oct 16 '16 08:10

uksz


1 Answers

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.

like image 58
xenteros Avatar answered Oct 16 '22 12:10

xenteros