Create a Package - .jar File
A package is a group of classes in the same directory. To construct a package:-
- Chose a name for the package, for example myPackage.
- Create a directory called myPackage.
- Place the .java files into the directory.
- Edit each .java file so that the first line reads:-
package myPackage
- Compile all the files in the directory.
- Create a .jar file of your package as outlined in the following instructions.
- Open a DOS box and change to the directory above myPackage.
- Type in the following command to create a file called myPackage.jar:-
jar cf myPackage.jar myPackage
- Copy myPackage.jar into your Java library:-
c:\ {java version} \jre\lib\ext\
e.g. c:\jdk1.4\jre\lib\ext\
- You can now use the classes in the package anywhere on your computer by importing the package:
Import myPackage.*;
|
|
To add an entry or request an existing one to be altered, please fill in the comments form
Return to Top
About Java
Main Index
(c) Compiled by B V Wood.
|
|
Main Index
UK SPONSERS
USA SPONSERS
|