| | |
java.lang.NoClassDefFoundError: ???
Thread Solved |
•
•
Join Date: Oct 2006
Posts: 179
Reputation:
Solved Threads: 2
Hi All
I was reading through the swing tutorial at http://java.sun.com/docs/books/tutor...t/compile.html
and i copied and pasted the provided source code for the HelloWorldSwing.java program.
It compiled fine but when i went to run it the following error message was returned
I have no idea what the error means, like i said i copied the source code from the sun site so i thought it would run ok so most likely there is something wrong with my pc.
Does anyone know whats wrong please?
Many thanks
HLA91
I was reading through the swing tutorial at http://java.sun.com/docs/books/tutor...t/compile.html
and i copied and pasted the provided source code for the HelloWorldSwing.java program.
It compiled fine but when i went to run it the following error message was returned
•
•
•
•
java HelloWorldSwing
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldSwing (wrong name: start/HelloWorldSwing)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Does anyone know whats wrong please?
Many thanks
HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
Well, actually those directions aren't quite correct on the tutorial page. The file they reference has a package declaration but they do not mention that and the command to run that file won't work as they have it written. Remove that package declaration and re-compile it and it should work fine.
If you leave in the package statement, you would need to have that class file in a directory called 'start' and from it's parent directory you would execute it as follows
Java Syntax (Toggle Plain Text)
package start;
If you leave in the package statement, you would need to have that class file in a directory called 'start' and from it's parent directory you would execute it as follows
Java Syntax (Toggle Plain Text)
java start.HelloWorldSwing
![]() |
Similar Threads
- Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error (Java)
- Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError (Java)
- java.lang.NoClassDefFoundError: java/lang/StringBuilder (Java)
- java.lang.NoClassDefFoundError: JBuilder (Java)
- exception in thread "main" java.lang.NoClassDefFoundError (Java)
- Following tutorials and getting java.lang.NoClassDefFoundError (Java)
Other Threads in the Java Forum
- Previous Thread: Please Help Compiling Error
- Next Thread: Running program as a domain user
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






