Exception in thread "main" java.lang.NoClassDefFounfError:
Hi, I'm kinda new at this java programming.
I use textpad as an editor, but when I have compiled my program I get this error each and every time I try to run the application:
Exception in thread "main" java.lang.NoClassDefFoundError: "name of the program".
I do realise that someone has already started a thread about this problem, but I don't understand what it is I have to do to solve the problem...
Is there anyone that can simplify it for me?
Thanks
/Peter
Hello
A good place to start would be going through this tutorial:
Your First Cup of Java: Detailed instructions to help you run your first program:
For UNIX:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html
Microsoft Windows:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
Mac:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/mac.html
> Exception in thread "main"
> java.lang.NoClassDefFoundError: "name of the program".
>
> Is there anyone that can simplify it for me?
>
It would be easier if you posted the full, exact error message. Do you try to run it from TextPad or from the command line?
Let's say your program is called Hello. When you compile Hello.java, the compiler produces a file named Hello.class. Let's say Hello.class is in the directory c:\myjava. Then, run it with the commandjava -classpath c:\myjava HelloRemember that Java is case sensitive.
I have a similar problem. It cannot be solved no matter how I modify the classpath, I have solved it by modifying the path instead.
When I set path=C:\Windows\System32;C:\Sun\AppServer\jdk\bin, I get the java.lang.NoClassDefFounfError, but when I set path=C:\Sun\AppServer\jdk\bin;C:\Windows\System32, it works fine. In both cases the classpath is the same, and both compile successfully, the only difference is the former cannnot run.
Does anyone know why? I thought only the classpath matters at runtime. In fact I did not have this problem a month ago, it started to occur last week, is this because I have installed something wrong into C:\Windows\System32 accidentally?
> When I set
> path=C:\Windows\System32;C:\Sun\AppServer\jdk\bin, I
> get the java.lang.NoClassDefFounfError, but when I set
> path=C:\Sun\AppServer\jdk\bin;C:\Windows\System32, it
> works fine. In both cases the classpath is the same,
> and both compile successfully, the only difference is
> the former cannnot run.
>
I think you will find a java.exe file in C:\windows\system32 that is either a Microsoft java.exe or the wrong version (or is somehow corrupted).