1
votes

I am trying to run a hello world java program on Netbeans but its giving me the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

I compiled and ran it on Command line and it worked. Then, I went back to Netbeans and I ran it again..this time it worked (because HelloWorld.class file is under the src folder). After deleting the .class file from the folder, it did not run again on Netbeans.

It is something to do with Netbeans but I can't seem to figure out what would fix this issue. I checked under project properties -> Libraries -> and the java platform is set to JDK 1.6

I am using Netbeans 7.0 on Mac.

Please help me out :(

1
you should include helloworld.java(src file for helloworld calss) in your projectVivek Goel
Can you describe the structure of the Project Folder, content of the folder?Serhiy

1 Answers

0
votes

NetBeans is running .class file not .jar when you run project. Usually it runs .class from build/classes directory. If you provide description of your project structure (or even screenshod) we could tell more. Here is detailed tutorial how to create and run Hello World app in NetBeans.