jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "packages" Watch "packages" New topic



Joined: Sep 15, 2003
Posts: 7
when we create packages of our own, where is it supposed to stored and accessed?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Well, anywhere you want it. I am not sure in what context you are asking. Packages for Applications are usually stored in some ROOT file structure of that application and then it's package subdirectories. Most people developing java apps will have a lib folder where they will put JAR files (which are just zipped packages).
In web apps, it just depends on if you are talking about Servlets that are in a package structure, or other helper classes you have written.
As long as they are accessable by the application (via the classpath) they can go anywhere. But there is typically a norm on where to put them.
If you could be a bit clearer on what you mean by your question, it might be easier to give you an explination.
[ September 15, 2003: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

On an aside, we have a naming policy here at Javaranch that states we don't allow obvious fictitous names. Please adjust your display name to meet our guidelines. You can change your display name here
Thanks a lot and welcome to Javaranch.
Also, who is this Indain Godess Kali? I would be interested in knowing who you hold in such high regards.
[ September 15, 2003: Message edited by: Gregg Bolinger ]
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
When you create a package you can access that package by putting in in your CLASSPATH at runtime. For example lets say you created a package named com.domain.myapp. You created your directory structure com -> domain -> myapp -> class files and compiled and created a jar file named myapp.jar. If you wanted to use that package in another application you were writing you could simple include it in your class path like this: java -classpath myapp.jar. I hope this helps.
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Suppose I am creating a package called packA in Top Folder.In packA I have another folder called gaya3 and in it I store my Java files.
packA.gaya3->First.java (First pprog in the package)
I need to set the class path to Top (Folder immediately above packA) and in my java progs (First and Sec), the first line should be
package packA.gaya3;
they should be compiled from Top folder as
javac packA/gaya3/First.java
Prasanna Kumar R.V
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Saraswathi!
You might want 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]
I agree. Here's the link: http://aspose.com/file-tools
subject: packages
It's not a secret anymore!