0

I am trying to compile my Java code.

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

I am using Jetbrains IntelliJ IDEA 15. I try to run my sample code and this is the error I get.

/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/bin/java Exception in thread "main" java.lang.ClassNotFoundException: HelloWorld at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:188) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

Process finished with exit code 1

I am not sure what is the problem here. I was trying to search this problem in the internet but the answers I was reading were for running my code through a command line.

user207421
  • 305,947
  • 44
  • 307
  • 483
bhsingh
  • 101
  • 1
  • 8
  • 14
  • probably a duplicate. You can copy the snippet into google, and go in to the first result that comes up, which tells you to reset your preferences. – hs2345 Jan 09 '16 at 18:05
  • 1
    Possible duplicate of [Error in intelliJ IDEA Hello World program](http://stackoverflow.com/questions/17300318/error-in-intellij-idea-hello-world-program) – gmode Jan 09 '16 at 19:17
  • This a runtime error, not a compile error. – user207421 Jan 10 '16 at 09:23

2 Answers2

0

If you're creating the run configuration manually, and not using IntelliJ IDEA's support for running a class by clicking the gutter icon next to the main method, you need to specify the correct class name to run, including the package name. For your example, this is "Test.HelloWorld" and not just "HelloWorld".

yole
  • 92,896
  • 20
  • 260
  • 197
-1

see the image

click here to see the image

See image and good luck!

YoungHobbit
  • 13,254
  • 9
  • 50
  • 73
Darya
  • 1