7

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.

uksz
  • 18,239
  • 30
  • 94
  • 161
  • 1
    Typically IntelliJ uses `src/main/java/` as the source folder. Does `Main` mean `Main.java` or `Main`, the directory? – OneCricketeer Oct 16 '16 at 08:17

1 Answers1

7

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.

xenteros
  • 15,586
  • 12
  • 56
  • 91
  • Could also try just creating a new project and copy&paste old src files to it. – Essej Oct 16 '16 at 08:21
  • 2
    Yes, in this case yes, but in the future, when someone comes here with same problem with huge project, he won't :) – xenteros Oct 16 '16 at 08:22