• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

NoClassDefFound error

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you actually have the programs in the subdirectories that the packages indicate that they are in?
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup. Any other ideas?
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THAT DID IT!! Thanks from the bottom of my heart!
Now I can go home!
Have a GREAT weekend!
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You too!
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys! I appreciate your help!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic