wood burning stoves*
The moose likes Java in General and the fly likes Packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Packages" Watch "Packages" New topic
Author

Packages

kallis kals
Greenhorn

Joined: Jul 18, 2006
Posts: 4
Hai everybody I am new to this forum ,

I have a doubt in (packages) concept, i.e after we create our own package how to work with that package.Means how to import package, and make the classes in it work in some other class outside the package.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61104
    
  66

"kallis ch",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
Some of the rules or look will depend on your environment. Essentially, each package exists in a folder bearing the package name. These packages can be nested, and as they are, their folders will show the same leveling. The source code for each file will reside in its folder.

For the most part, the packages that you create should have their source folders in the "src" folder of your Java environment. When compiled, their class files will be set up in the Java "classes" folder using the same folder structure.

You can import classes from package to package using the "import" command and the folder structure (from the "classes" level) followed by the class name. Normal rules of accessability apply. You can only access public methods from outside the package.


Darryl Failla
Sun Certified Java 2 Programmer
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Packages