Results 1 to 12 of 12
Thread: noClassDefFoundError
- 08-21-2010, 02:24 PM #1
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
noClassDefFoundError
I am currently making a game and my software is getting pretty big (relativly, 9 classes, about 600 lines of code) and suddenly eclipse stops excecuting my program. When I try to run or debug my program it says there is an error in my code, but nowhere in my code it shows an error. When I run my code anyway, I get this:
It seems to me it can't find the main tester class, which is just:Java Code: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 when debugging, it never reaches the first line of code ("new callEDitor();"), I gues that isn't the problem. It seems eclipse can't find the tester class itself, which is odd because I haven't changed that class since yesterday and the program ran perfectly yesterday.Java Code:import java.awt.*; import java.util.*; import javax.swing.*; public class tester { public static void main(String[] args) { new callEditor(); } }
Can anyone point me to the problem?
- 08-21-2010, 03:11 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you define that constructor in the relevant class? My concern is that you've save the file with the same class name?
- 08-21-2010, 03:31 PM #3
What happens if you open a command prompt, change to the folder with the tester.class file and enter:
java tester
- 08-21-2010, 04:04 PM #4
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
@Eranga: I checked, the class name is the same name as the saved name.
@Norm: how do I change folders in the command prompt?
- 08-21-2010, 04:07 PM #5
Use the cd command: cd dirname
To go up on level: cd ..
Use the dir comand to see the contents of the current directory.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
- 08-21-2010, 04:32 PM #6
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
Thanks for the help, here is the error I got:
Java Code:Exception in thread "main" 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) Could not find the main class: tester. Program will exit.
- 08-21-2010, 04:44 PM #7
You left off the command that you entered to get the error.
Is the tester.class file in the current directory?
Here is what I get when I issue a java command for a missing class file:
Make sure there is a tester.class file in the folder before issuing the java command.Java Code:D:\Testing>java asdfasdfasdf Exception in thread "main" java.lang.NoClassDefFoundError: asdfasdfasdf Caused by: java.lang.ClassNotFoundException: asdfasdfasdf 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) Could not find the main class: asdfasdfasdf. Program will exit.
- 08-21-2010, 05:06 PM #8
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
Well, all my class files are .java files, so there isn't a tester.class file. I do know for certain that there is a tester.java file in that directory.
- 08-21-2010, 05:36 PM #9
None of your 'class' files have the .java extension. Class files are the output of the javac compiler. Java files are source files that are compiled to class files.all my class files are .java files,
There MUST be a .class file for the java command. .java files are NOT used by the java command.
You create a .class file from a .java file by compiling the .java file.
Use the javac command to create the .class file.
The problem is you are using an IDE that has many folders with different contents. Some for .java files and some for .class files and some for other files.
If you try to bypass the IDE and do steps manually without understanding how the IDE works, you'll have problems.Last edited by Norm; 08-21-2010 at 05:39 PM.
- 08-21-2010, 06:24 PM #10
Senior Member
- Join Date
- Aug 2010
- Posts
- 127
- Rep Power
- 0
But the whole problem is that the IDE is giving the error message. The only reason I tried to bypass it manuelly is because you asked me to, and that just gave exactly the same error message.
- 08-21-2010, 06:46 PM #11
Sorry, I don't know how to use your IDE.
If you go to the folder with the tester.class file and enter:
java tester
The java program will start executing the tester class.
If there is no tester.class file, go to the folder with the tester.java file and enter:
javac tester.java
Then do
java tester
-
Moved to the Eclipse forum per the OP's request.
Similar Threads
-
NoClassDefFoundError
By Dbirge in forum New To JavaReplies: 0Last Post: 03-16-2010, 05:01 PM -
help with NoClassDefFoundError
By chikoyzki06 in forum New To JavaReplies: 2Last Post: 11-25-2009, 11:38 AM -
Message NoClassDefFoundError
By karim in forum EclipseReplies: 1Last Post: 03-20-2009, 03:43 PM -
Getting NoClassDefFoundError through quicktime API
By sunil.mact in forum Advanced JavaReplies: 3Last Post: 01-23-2009, 02:59 PM -
NoClassDefFoundError
By jon80 in forum New To JavaReplies: 3Last Post: 05-18-2008, 12:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks