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 How to create a package? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to create a package?" Watch "How to create a package?" New topic
Author

How to create a package?

ada choi
Greenhorn

Joined: Sep 08, 2004
Posts: 16
i saw some of the JSR172 codes have this package line in the java codes. What is it for and how do i create a package file?

package example.serverscript.connector;
package example.serverscript.demo;
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Moving this to Java in General forum.
Folks their may help you. Java in General


Spritle Software Blogs
Anamika Agarwal
Greenhorn

Joined: Sep 07, 2004
Posts: 5
package example.serverscript.connector;
package example.serverscript.demo;

These lines indicate that the package example contains a package serverscript which contains another package connector.Similarly for second line the serverscript package contains a package called as demo.
To create a package file u have to write simply a line in the begining of the file.
package packageName;
And u have to create the directory with the packageName and keep ur file there.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Creating a package is as simple as declaring that a class, interface or enum definition belongs in a package as the first non-comment line of code in a source file.In this simple example, class Foo is a member of the fubar package.

You might like to take a look at the "Creating and Using Packages" lesson of Sun's Java Tutorial.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
GeeCON Prague 2014
 
subject: How to create a package?