File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes NoClassDefFound error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFound error" Watch "NoClassDefFound error" New topic
Author

NoClassDefFound error

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hi. I am using TextPad to compile and run my java apps. Everything works great here. Whenever I try to run my class from a DOS prompt, I get the NoClassDefFoundError- wrong name. Why does it work in TextPad but not through DOS?
My classes are in packages: "com.storekraft.util"
The parent directory is I:\VSK Java Programs.
I have the parent directory listed in my classpath. Am I missing something?
Any help would be greatly appreciated!!
Thanks!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
When you invoke the class are you spelling it exactly the same, including capitalization? And is your file name the same as the class that it contains, including capitalization?


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

Joined: Feb 28, 2001
Posts: 455
Thanks for the reply!
Yes, the file name is the same as the class name. I have also keyed it in exactly as it is, including capitalization.
Any other clues??
Thanks again!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Do you actually have the programs in the subdirectories that the packages indicate that they are in?
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Yup. Any other ideas?
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Me again. I just tried something. I was able to run a couple of other classes through DOS and they worked OK. The difference between the one I can't run and the ones I did run, is that there are numerous classes involved in the one that won't run. Does this help any?
Thanks again!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
And your package statement in your program is actually the way it is in DOS?
It's that "wrong name" thing. SOMETHING is not spelled correctly or lcoated correctly.
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Cindy,
this is my package statement in my program:
com.storekraft.util
What do you mean by the package name being the same as in DOS?
All I'm keying in DOS to run the program is java ProjectMaintenance while in the directory I:\VSK Java Programs\com\storekraft\util
Is this wrong? Maybe I don't understand running programs that are in packages that well.
Thanks again for your help!
[ April 12, 2002: Message edited by: Jennifer Sohl ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Ah!!!
You need to be sitting somewhere NOT in the middle of one of your packages. Like at
>I:\VSK Java Programs
Try that.
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
THAT DID IT!! Thanks from the bottom of my heart!
Now I can go home!
Have a GREAT weekend!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You too!
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hello Again! Now that I can run my app from DOS, the next step I am trying to accomplish is running the app from my desktop. I have created a shortcut with the Target as follows:
C:\Java\j2re1.4.0-rc\bin\javaw.exe -cp I:\VSK Java Programs\JSQLConnect.jar;I:\VSK Java Programs\ProjMain.jar ProjectMaintenance
Everytime I try to run it I get the message: Cannot Find main class. Program will exit!
I created a manifest file that looks like this:
Main-Class: ProjectMaintenance
I even made sure there is a newLine after that statement.
I have other apps running through shortcuts on my desktop, however, they are not in packages.
I must be missing something in that department??
Can someone tell me why it can't find my main class?
Thanks again!!
[ April 15, 2002: Message edited by: Jennifer Sohl ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
First of all, it is probably better to put all the classpath and invoking stuff in a .bat file and then just point you icon at that. It is also easier to edit that way.
Which direcory in your jar is the ProjectMaintenance.class file in?
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hello Cindy. You're not going to believe it, but I have never done anything with .bat files.
I don't know how to put all of this into one, or where to place the .bat file.
As far as the directory that ProjectMaintenance.class is in:
I:\VSK Java Programs\com\storekraft\util
Could you show me how to do this?
Thanks a million!
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Hi Jennifer
A bat file is basically a set of DOS instructions that are run sequentially when the bat file is opened.
For more on bat files in general:
http://home7.inet.tele.dk/batfiles/intro/intro.htm
http://gatsby.tafe.tas.edu.au/batch/index.htm
http://home.att.net/~gobruen/progs/dos_batch/dos_batch.html#batch
As far as what you want to do all you need to do is create a text file and enter all of the commands in it that you are doing on the commnand line to run your program, your text file might look something like this:
:: start of bat file
javaw -cp I:\VSK Java Programs\JSQLConnect.jar;I:\VSK Java Programs\ProjMain.jar ProjectMaintenance
pause
:: end of bat file
The double :: are comments in the bat file, I put the pause in there so the DOS window does not close right away when it is done executing. You can create a shortcut to the bat on your desktop if need be.
Just make sure javaw is in your path and you should be good to go.
When our done just rename the file with a .bat extension
hope that helps.


Dave
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Try fully qualifying your class name in your Manifest:
Main-Class: com.storekraft.util.ProgramMaintenance
So use Notepad or whatever and create a file called MyApp.bat and put the DOS commands in there. You can save it to any directory in the path and the system will find it.
If you do this you really do not need a manifest to run your app. Just include the jar file in the classpath and invoke the fully qualified name of the class that has the main.
MyApp.bat
---------------------------------
cd c:\whatever\ifYouWant
C:\Java\j2re1.4.0-rc\bin\javaw.exe -cp I:\VSK Java Programs\JSQLConnect.jar;I:\VSK Java Programs\ProjMain.jar com.storekraft.util.ProjectMaintenance
----------------------------------
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Thanks guys! I appreciate your help!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFound error