Home » Newcomers » Newcomers » java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError [message #554355] |
Sun, 22 August 2010 09:54 |
imorio Messages: 1 Registered: August 2010 |
Junior Member |
|
|
Hi, I'm new to this forum, so tell me if I'm doing something wrong. My problem is this:
I've been using eclipse for some weeks now and it always worked perfectly, untill now. I have been working on my largest program yet. Now it consists of 9 classes and about 600 lines of code. But for some reason, after starting up my computer a few days ago, eclipse can't run it anymore.
When I try to run it, eclipse warns me that there are errors in the program. Yet nowhere in my program it shows red lines. When I run the program anyway, I get this exception:
java.lang.NoClassDefFoundError: tester
Caused by: java.lang.ClassNotFoundException: tester
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)
Exception in thread "main"
Because the exception occurs before the first line of code, debugging doesn't help. It seems to me the problem is that eclipse can't find the class. However in the blue (windows) bar on top, it does show the classpath of the class. Also, running other classes in other projects is no problem. The weirdest thing is that the error started when I shutdown and started my computer, without any changes to the tester-class.
Is there anyone who can help me with this?
|
|
|
Re: java.lang.NoClassDefFoundError [message #554372 is a reply to message #554355] |
Sun, 22 August 2010 16:03 |
David Wegener Messages: 1445 Registered: July 2009 |
Senior Member |
|
|
On Sun, 2010-08-22 at 05:54 -0400, a6277143@bofthew.com wrote:
> Hi, I'm new to this forum, so tell me if I'm doing something wrong. My problem is this:
>
> I've been using eclipse for some weeks now and it always worked perfectly, untill now. I have been working on my largest program yet. Now it consists of 9 classes and about 600 lines of code. But for some reason, after starting up my computer a few days ago, eclipse can't run it anymore.
> When I try to run it, eclipse warns me that there are errors in the program. Yet nowhere in my program it shows red lines. When I run the program anyway, I get this exception:
>
Open up the Problems view to find out what the errors are. My guess
would be some type of build path error.
> java.lang.NoClassDefFoundError: tester
> Caused by: java.lang.ClassNotFoundException: tester
> 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)
> Exception in thread "main"
>
> Because the exception occurs before the first line of code, debugging doesn't help. It seems to me the problem is that eclipse can't find the class. However in the blue (windows) bar on top, it does show the classpath of the class. Also, running other classes in other projects is no problem. The weirdest thing is that the error started when I shutdown and started my computer, without any changes to the tester-class.
>
> Is there anyone who can help me with this?
Check to make sure that the tester.class file exists. If you have build
path errors, you might not have a built class file. When java runs, it
needs the class files. I can't run against the java files.
|
|
|
Re: java.lang.NoClassDefFoundError [message #554419 is a reply to message #554355] |
Mon, 23 August 2010 05:06 |
Walter Harley Messages: 847 Registered: July 2009 |
Senior Member |
|
|
<a6277143@bofthew.com> wrote in message
news:i4qs4i$b28$1@build.eclipse.org...
> Hi, I'm new to this forum, so tell me if I'm doing something wrong. My
> problem is this:
>
> I've been using eclipse for some weeks now and it always worked perfectly,
> untill now. I have been working on my largest program yet. Now it consists
> of 9 classes and about 600 lines of code. But for some reason, after
> starting up my computer a few days ago, eclipse can't run it anymore.
> When I try to run it, eclipse warns me that there are errors in the
> program. Yet nowhere in my program it shows red lines. When I run the
> program anyway, I get this exception:
>
> java.lang.NoClassDefFoundError: tester
> Caused by: java.lang.ClassNotFoundException: tester
> 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)
> Exception in thread "main"
> Because the exception occurs before the first line of code, debugging
> doesn't help. It seems to me the problem is that eclipse can't find the
> class. However in the blue (windows) bar on top, it does show the
> classpath of the class. Also, running other classes in other projects is
> no problem. The weirdest thing is that the error started when I shutdown
> and started my computer, without any changes to the tester-class.
>
> Is there anyone who can help me with this?
Notice that there are two subtly different errors here: a
NoClassDefFoundError, and a ClassNotFoundException.
NCDFE indicates that a class was found but something it depended upon could
not be loaded. CNFE indicates that the class itself could not be found.
So, it may be that some class referenced by tester could not be found.
By the way, it's probably not related to your current problem, but just a
note: you can make your life easier in the long term by following the
conventions [1] for Java class naming. Typically, packages are named in
lower case, and classes are named in upper case; so your class would be
Tester, not tester. This can help eliminate a lot of confusion at times.
[1] http://en.wikipedia.org/wiki/Naming_convention_(programming)
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 11:35:03 GMT 2024
Powered by FUDForum. Page generated in 1.79938 seconds
|