File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

packages mechanics

 
Danny Ksomething
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just a beginner, but came across this packages subject, and it made mw curious: How does it work ? Does the compiler write some info in some "Registry like" file when i write the package statement ?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.
As a tip, if you do a search for "package" on this form, I'd bet you'll find plenty of information. The search page link is at the top-right of this page.
Otherwise, from Sun's Java Tutorial you might want to read the trail on Creating and Using Packages.
Good Luck.
 
Danny Ksomething
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, i tried to folloow the tips, but havent found an answer.
u c, i'd like 2 know the Java platform handles packages. Not HOW TO work with them. I suceeded doing that.
 
Nandu Arni
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we specify a package in java, it physically creates a directory in the file system. The package structure is just like an ordinary file system. For example, a file called foo.java is placed in dir1/dir/2/dir3/foo.java is exactly similar to
package dir1.dir2.dir3
class foo
{
}
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Danny Ksomething:
Well, i tried to folloow the tips, but havent found an answer.
u c, i'd like 2 know the Java platform handles packages. Not HOW TO work with them. I suceeded doing that.

Well, continuing down the path I recommended, you'll come across the page Managing Source and Class Files which would seem to me to describe what you are curious about.
The package heirarchy is quite similar to the directory heirarchy on a harddrive. The individual class file knows what package it belongs to (more or less) - it got this information when it was created (compiled).
Note: When you compile a file, it is NOT by default placed in the proper directory according to its package; but you may be using an IDE that takes care of this dirty work automatically.
Good Luck.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic