File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating a package of classes

 
Cyrus Serrano
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone give me an introductory on how classes can be package, please...
thanks...
Cyrus
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jacquie Barker
author
Ranch Hand
Posts: 201
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic