This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See 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.
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.,
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"?
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
posted 9 years ago
Thanks very much to both of you for your replies!
No, tomorrow we rule the world! With this tiny ad: