Error "ClassNotFoundException" in IntelliJ IDEA

Probably your project structure was src/main/java/start.java but when you added it to IntelliJ you have set src as a source folder, so IntelliJ put main.java as a package.

In Project Setting (Ctrl+Shift+Alt+S) → Modules → Sources tab set src/main/java as Source Folder. Then in your simple program change package to whatever you like (e.g. my.test). After that if IntelliJ reports any error in line with package quick fix with Alt+Enter should help


Above answers are fine. I would like to add an one more option if someone has any dependency with scope as provided then following configuration is needed.

Run -> Edit Configurations -> Include dependencies with "Provided" scope.

Mark the tick box, apply and run.


I had this problem and couldn't solve it with any of these solutions. However I think the problem was that I was using 'open' to create a project from a directory with some java files in. Instead I had to 'create new project' with the same directory as root.

Make sure you delete any '.idea' directories and '.iml' files when 'create new project' since it will otherwise complain about a project already being in the given directory.