File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes java package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java package" Watch "java package" New topic
Author

java package

bala kan
Ranch Hand

Joined: Aug 20, 2012
Posts: 44
i know somewhat about packages concept..in this concept, we can create classes of our own and put it in package.. then how to access and use those classes in our program.. please explain by giving a simple java program..

thanks in advance
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
You should find most of your questions answered here, but come back if you have more.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Welcome to the Ranch, Bala Kan.

Packages are used for logical grouping of Java classes. You can use the package members by importing them in your Java class. Read more on how to import them here - Using Package Members

Packages helps in distinguishing classes when you are bound to use two or more classes with the same name. Hence note that two classes with the same name can never be present inside a package.

Note that there are access modifiers that restrict package member usage. Also the Java class files should be present in the directory named after the package it's present.

Sample code : Greetings.java resides in the package named myPackage and the Welcome class access it's method.

Greetings.java:


Welcome.java


As you are new here, I advise you to SearchFirst in JavaRanch and get good old discussions on the queries you have.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java package