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.

3
  • 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. Commented Jan 9, 2016 at 18:05
  • 1
    Possible duplicate of Error in intelliJ IDEA Hello World program Commented Jan 9, 2016 at 19:17
  • This a runtime error, not a compile error. Commented Jan 10, 2016 at 9:23

2 Answers 2

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".

Sign up to request clarification or add additional context in comments.

Comments

-1

see the image

click here to see the image

See image and good luck!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.