This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes HELP! default package access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HELP! default package access" Watch "HELP! default package access" New topic
Author

HELP! default package access

Binkie Hayes
Greenhorn

Joined: Mar 14, 2001
Posts: 20
Hey guys
I've got a bit of a dumb question that's got me all confused!
I've got 2 directories, Folder1 and Folder2 on my C drive, and I've set my classpath to point to Folder1.
In Folder1 I've got this class:
class MyDefaultClass
{
static{System.out.println("Howdy, y'all!");
}
In Folder2 I've got this class:
class Test
{
public static void main(String []args)
{
MyDefaultClass x = new MyDefaultClass();
}
}
Now, I was thinking that Test wouldn't compile because MyDefaultClass is in the default package and the 2 classes are in different directories, but it compiled no problem. I'm presuming it has something to do with the classpath but i dont know what!! any ideas please??! am v confused!
thanks y'all!
binkie
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Your classpath tells your application where to look for those files. Since the folder containing MyDefaultClass is in the class path, it searches that folder for that class, finds it, and there ya have it.
Try this. Move your MyDefaultClass stuff to another folder off that drive, but one that is not in the class path. Should get a compilation error.
Jason
 
GeeCON Prague 2014
 
subject: HELP! default package access