Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.NoClassDefFoundError: TestConWindow

 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.NoClassDefFoundError: TestConWindow
Uggghhhh! This program worked fine until today!!! It must be a Classpath thing, but I can't figure it out. The class compiles fine but then receives this error when I try to execute. Could this message be any LESS helpful?
Here is the code. The 'User' class is in the same directory as the TestConWindow.class ... I had a classpath problem with this last week which I got around by compiling with -classpath. That is the only way I could get the program to compile and adding .; to my classpath does not work.

Thanks if anyone can help.
Pulling my hair out...
------------------
I'm a soldier in the NetScape Wars...
Joel
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joel,

In your code, you are specifying that your TestConWindow is in the camra2 package... if you are in the same directory as the class file, try running it this way :


You have to specify the directory directly before the beginning of your package in the classpath, and if a class is a member of a package, you have to specify it's full name (i.e. full package path + class name) on the command line.

HTH,
-Nate
 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've removed the package reference. Both Classes are in the same directory. They both compiled fine. My classpath includes the current directory. I tried running the program without -classpath and with -classpath. No matter what I receive the same error:

I don't know what else to do, I don't see anything wrong with the code (same as above w/o package statement), "main" obviously exists, I'm not running the program with ".java" extension, my classpath is set and complete.
Going bald...
------------------
I'm a soldier in the NetScape Wars...
Joel
 
navin kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
U first set the classpath in environment file i.e.
"autoexec.bat" file. there set as follows
classpath=c:\jdk1.3\<package name>

If further more doubts regarding this U can post here
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm really confused about this one...

I've been trying to test your code and there doesn't look like there should be any problem... the only suggestion I can make is to check out the logic in the Class.forName related stuff... in the spoofed User class I made to test your code, if I was returning bogus info ( i.e. a class that did not exist ), I got a similiar error message... strangely, you should not get that error message if you were making the same mistake I was, because the TestConWindow class obviously exists....

Sorry I couldn't help more...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic