• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

NoClassDefFoundError =(

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Leroy J Brown
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Leroy J Brown
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much to both of you for your replies!

 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic