This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes accessing classes from a package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "accessing classes from a package" Watch "accessing classes from a package" New topic
Author

accessing classes from a package

aleks nikolic
Greenhorn

Joined: Mar 04, 2001
Posts: 25
What's going on when you get error like :
cannot access Line
bad class file : .\Line.class
class file contains wrong class : home.geometry.Line
Please remove or make sure it appears in the correct subdirectory of the
classpath
I have the subdirectory of \home\geometry in my CLASSPATH . Line is part
of package home.geometry and is in \home\geometry . So I don't get it .
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
\home\geomerty should not be in your classpath, instead the root of the class tree should be.
For example, if I have a class home.geometry.Ugh located in c:\java\stuff\home\geometry\Ugh.class then my classpath should contain c:\java\stuff
The Java classloader will automatically add the "\home\geometry" for you because the class is in the package home.geometry.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
aleks nikolic
Greenhorn

Joined: Mar 04, 2001
Posts: 25
Yeah , sorry I stated it wrong . home\geometry is not in my class path , the root is .
I find if I set classpath at the command line it works though . So it appears it was checking the current directory first and that was screwing it up . If I set at command line , then it doesn't check current directory .
Probably if I set my environment CLASSPATH with current directory coming after package root , it would be OK also.
 
jQuery in Action, 2nd edition
 
subject: accessing classes from a package
 
Similar Threads
classpath issue
package problems
package problems
New error, what does it mean?
importing root stuff