java.lang.NoClassDefFoundError: ???

Thread Solved

Join Date: Oct 2006
Posts: 179
Reputation: HLA91 is an unknown quantity at this point 
Solved Threads: 2
HLA91 HLA91 is offline Offline
Junior Poster

java.lang.NoClassDefFoundError: ???

 
0
  #1
Jul 22nd, 2008
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

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)
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
You know your a geek, if you introduce your wife as "mylady@home.wife"
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,427
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: java.lang.NoClassDefFoundError: ???

 
1
  #2
Jul 22nd, 2008
Well, actually those directions aren't quite correct on the tutorial page. The file they reference has a package declaration
  1. package start;
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
  1. java start.HelloWorldSwing
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 179
Reputation: HLA91 is an unknown quantity at this point 
Solved Threads: 2
HLA91 HLA91 is offline Offline
Junior Poster

Re: java.lang.NoClassDefFoundError: ???

 
0
  #3
Jul 22nd, 2008
OK thanks, i removed the package declaration and it was all good, thanks for the info, strange that the tutorial didnt mention anything about it though and I would have expected them to, if it was going to affect the compilation
You know your a geek, if you introduce your wife as "mylady@home.wife"
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,427
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: java.lang.NoClassDefFoundError: ???

 
0
  #4
Jul 22nd, 2008
I suspect it was merely an oversight and needs to be corrected on that page.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 62
Reputation: tactfulsaint is an unknown quantity at this point 
Solved Threads: 0
tactfulsaint tactfulsaint is offline Offline
Junior Poster in Training

Re: java.lang.NoClassDefFoundError: ???

 
0
  #5
Jul 24th, 2008
its a classpath error check your classpath.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,427
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: java.lang.NoClassDefFoundError: ???

 
0
  #6
Jul 24th, 2008
Originally Posted by tactfulsaint View Post
its a classpath error check your classpath.
No, it is not a classpath problem. It's a package declaration problem as already stated.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC