aspose file tools*
The moose likes Beginning Java and the fly likes NoClassDefFoundError   =( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFoundError   =(" Watch "NoClassDefFoundError   =(" New topic
Author

NoClassDefFoundError =(

Leroy J Brown
Ranch Hand

Joined: Dec 02, 2007
Posts: 71
Okay friends,

So I'm rather confused about this class loader process and why it doesn't want to go about its business in the manner I expect. I normally use eclipse and I suppose it has become a crutch as this problem demonstrates.

I have read How To Set The Classpath
I can run any project I want in eclipse just fine. However I can't run anything from the command line as I want to. Below should be an image I took of my classpath side by side with my CMD line. Here you can see:

1) Searching for my desired file
2) evidence that such a file exists in this directory
3) me attempting to call this class's main method
4) the error
5) my CLASSPATH variable showing clearly that ".;" ie my current directory is part of the path and therefor (I thought) the class loader should be able to find it.

advise on how to solve this problem would be greatly appreciated.

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi Tristan,

That "wrong name" message is actually telling you that Java *did* find the class file, but it wasn't the file that Java expected. You asked it to run the class named GetPath, and it found the file GetPath.class, but the file does not contain the class named GetPath -- it contains the class named com.tristanjrouse.archive.GetPath .

The general solution to this is to "cd" into JavaSandbox\bin and then run the class using its full name; i.e.,

C:\ ...JavaSandbox\bin> java com.tristanjrouse\archive\GetPath

and that will work just fine!


[Jess in Action][AskingGoodQuestions]
Leroy J Brown
Ranch Hand

Joined: Dec 02, 2007
Posts: 71
Ernest!

Thanks much for your reply. Just so that I understand what is happening here, when you say that Java found the class but it had the "wrong name"... does Java determine this "name" by its package statement? if not, how does it decide how much of the fully qualified path is included in the class's "name"?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Tristan Rouse:
... does Java determine this "name" by its package statement? ...

Yes, the fully qualified package name is part of the fully qualified class name.

JLS 6.7...
The fully qualified name of a top level class or top level interface that is declared in a named package consists of the fully qualified name of the package, followed by ".", followed by the simple name of the class or interface.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Leroy J Brown
Ranch Hand

Joined: Dec 02, 2007
Posts: 71
Thanks very much to both of you for your replies!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError =(