This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes No Class Def Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "No Class Def" Watch "No Class Def" New topic
Author

No Class Def

cardwell cupp
Ranch Hand

Joined: Aug 16, 2001
Posts: 66
I have been working on a project with packages and can get it to compile and run using a plain old applet viewer, but when it comes to running it in a browser, I get the infamous
java.lang.NoClassDefFoundError: pack1/pack1a/pack1b/ProjBase
I have tried to reset the classpath thinking that could be it(working with Win 98)
'set classpath=d:\project1\pack1\pack1a\pack1b'
That didn't work...
So I took the ProjBase and combined it with another class in the same package(one that inherited from it). Then I got the same exception, now with the JApplet class. So I added the swingall.jar file into the classes folder of netscape...that took care of that problem, but then I received another no class def exception now for pack1/pack1a/pack1b/pack1c/ProjMainFrame
I am lost...Sorry for the book I just wrote.
Is there another way of fixing this problem???
Thanx
Cardwell
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The classpath should point to the top directory that contains the package directories. The classpath should NOT mention the package directories themselves.
If the top directory is d:\project1
'set classpath=d:\project1'
Then the package statements in the class file should be on the order of
package pack1.pack1a
and the class file that holds that statement should be in
d:\project1\pack1\pack1a\whatever.class
When you named the package directories in your classpath you confused the JVM.

"JavaRanch, where the deer and the Certified play" - David O'Meara
cardwell cupp
Ranch Hand

Joined: Aug 16, 2001
Posts: 66
Thanks for the reply...
I went ahead and changed the classpath to the root most directory, and tried it...But the same problem occurs. I went ahead and tried it with every directory starting with d: upto ..\pack1b\ but still no luck..
I am sorry to be annonying... it is just that this has me stumped. Does it matter that I have two drives? Coperating system) d: project, netscape and jdk. It shouldn't as long as the class path is correct.?
Could this be anything else than a classpath problem...
What would be a good debugging technique for this...
Thank you soo much for your help..
Cardwell
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Did you actually check to make sure that the .class files are in the directory that their package statement promises?
And if you are using an Applet what is your DocumentBase and CodeBase? Is your JApplet class actually sitting in the d:\project1 directory?
Having two drives is not a problem, I run off the d: drive.
cardwell cupp
Ranch Hand

Joined: Aug 16, 2001
Posts: 66
Thanks for taking the time
html
applet code = pack1.pack1a.pack1b.Proj width = 640 height = 340
PARAM name = properties value = "proj.properties"
/applet
the html page itself is in the root directory of the project. Proj.class is a class that inherits the ProjBase.class.
Both of them are there in the directory...

Thanks
Cardwell


[This message has been edited by cardwell cupp (edited August 16, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: No Class Def
 
Similar Threads
I'm hopeless ....
packages and classpath! or at least i guess!
import mypack.*; (asterisk and without asterisk)
Package still not working
Classpath