| Author |
creating a package of classes
|
Cyrus Serrano
Ranch Hand
Joined: Sep 29, 2003
Posts: 137
|
|
can anyone give me an introductory on how classes can be package, please... thanks... Cyrus
|
 |
Sainudheen Mydeen
Ranch Hand
Joined: Aug 18, 2003
Posts: 218
|
|
Hi http://java.sun.com/docs/books/tutorial/java/interpack/packages.html -Sainudheen
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
Sometimes when folks are talking about packaging some Java classes, they're talking about putting them together in a JAR file. Take a look at The Jar Files Trail of Sun's Java Tutorial for such instructions and information.
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Jacquie Barker
author
Ranch Hand
Joined: Dec 20, 2000
Posts: 201
|
|
Determine the name of the package, then in each class that is to belong to that package, put in the statement: package com.mypackage; // or whatever the name is to be ahead of all import statements. When you compile your source code, use the command: javac -d . *.java to cause all of the .class files to be stored in a subdirectory beneath the working directory whose path matches the path name; in the case of my example above, if my source code were in a directory called /mycode, then the .class files would wind up in a directory called /mycode/com/mypackage. Next, use the following command jar cvf somename.jar com to bundle up, as a Java archive, all of the code in your package. Anyone wanting to use your package would have to (a) import com.mypackage.* and (b) have your jar file in their classpath. Hope this helps!
|
Author of Beginning Java Objects, Beginning C# Objects, and Taming the Technology Tidal Wave
|
 |
 |
|
|
subject: creating a package of classes
|
|
|