Java package: Difference between revisions

Content deleted Content added
Cleaned up (ahem re-written) following comments in the cleanup page
No edit summary
Line 1:
Java Source Files belonging to the same category or provide similar functionality can be packed into a Java Package. Java Packages are stored in compressed files called [[Jar (file format)|jar]] Files. Inside the package the files can be stored hierachically, therefore it is possible to combine several subdirectories into one package.
Related [[Datatype|types]] in Java are placed in a common package.
 
*A package provides a unique [[namespace|namespace]] for the types it contains.
*A package facilitates access protection.
Line 8 ⟶ 9:
**Annotations
 
ATo use a package isinside represented ina Java codeSource byFile, ait seriesmust ofbe textualimported names delimited bywith the '.' (dot)import character.statement,
e.g. import java.awt.event.*;
e.g
 
import java.awt.event.*;
This imports all files from the directory java/awt/event
 
==Packages in Java 1.5==
 
* java.lang, java.util: These packages provide basic language functionality like regular expressions, the Reflection API
* java.math: provides mathematical functions
* New I/O: the new I/O framework for Java
* I/O: File Operations
* Networking: Networking Operations, Sockets, DNS lookups,...
* Security: key generation, encryption and decryption
* Java Database Connectivity (JDBC): to access databases
* Java AWT: set of packages for GUI
* Java Swing: native Java GUI components
 
== Creation of Jar Files==
 
In the Java Source Files the package the file shall belong to must be specified with the package keyword, e.g.
/package java/.awt/.event
 
Jar Files are created with the jar command-line utility. The command
And is stored on disk {or in a compressed file such as a [[Jar (file format)|jar]] or Ear (Enterprise Archive)}
as a series of nested directories.
e.g.
/java/awt/event
 
jar cf myPackage.jar *.class
 
compresses all *.class files into the Jar File myPackage.tar.
 
{{compu-lang-stub}}