12

I recently installed intellij IDEA 14.0 and to make sure everything was working I created a simple Hello World program. I do not understand why the output is not correct and why I am getting this error. If someone could please help that would be great.

This is the program:

public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}

This is the error:

Exception in thread "main" java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
kayanushpatel
  • 471
  • 2
  • 5
  • 6
  • Isn't that a duplicate of http://stackoverflow.com/questions/16857849/intellij-suddenly-throwing-classnotfoundexception ? – Gabriel Jan 10 '15 at 00:20

3 Answers3

4

The reason you're getting this error is because you didn't save the class into a file called Hello.java (case-sensitive!)

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
3

This is just problem of intellij IDE.

Solution Steps:

  1. CtrlShiftAlts -> Preject Setting -> modules tab -> expand <project_name> and go to <project_name>_main
  2. refer Image: SS1
  3. In Sources tab -> ** click on x symbol**

SS2

  1. click YES
  2. Right click on SS4 -> sources
  3. Apply and OK

Finally build your project.

SS7

Enjoy.

slava
  • 791
  • 1
  • 11
  • 26
ankit
  • 2,591
  • 2
  • 29
  • 54
0

It usually happens with IntelliJ.

I solved it deleting all modules and only leaving which have more hierarchy

The other modules(like main or test) are already part of product

dmarquina
  • 3,728
  • 1
  • 28
  • 28