Content deleted Content added
Clemens vi (talk | contribs) No edit summary |
Added {{expert}}; some reorganization; added links to API Javadoc; expanded explanation of using packages |
||
Line 1:
{{expert}}
Java
*A package provides a unique [[namespace|namespace]] for the types it contains.
Line 6 ⟶ 7:
**[[Class (computer science)|Classes]]
**[[interface (computer science)|Interfaces]]
**[[Enumeration|Enumerated Types]]
**[[Annotation]]s
== Using packages ==
e.g. import java.awt.event.*▼
To use a package inside a Java source file, it is convenient to import the classes from the package with an <code>import</code> statement. The statement
==Packages in Java 1.5==▼
imports all classes from the <code>java.awt.event</code> package, while
* 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▼
* Networking: Networking Operations, Sockets, DNS lookups,...▼
* Security: key generation, encryption and decryption▼
* Java Database Connectivity (JDBC): to access databases▼
== Creation of Jar Files==▼
imports only the <code>ActionEvent</code> class from the package. After either of these import statements, the <code>ActionEvent</code> class can be referenced using its simple class name
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
ActionEvent myEvent;
Jar Files are created with the jar command-line utility. The command▼
Classes can also be used directly without an import statement by using the fully-qualified name of the class. For example,
jar cf myPackage.jar *.class▼
java.awt.event.ActionEvent myEvent;
compresses all *.class files into the Jar File myPackage.tar.▼
doesn't require a preceding import statement.
▲In
package java.awt.event;
▲ jar cf myPackage.jar *.class
▲* {{Javadoc:SE|package=java.lang|java/lang}}, {{Javadoc:SE|package=java.util|java/util}}: These
▲* {{Javadoc:SE|package=java.math|java/math}}: provides mathematical functions
* {{Javadoc:SE|package=java.io|java/io}}: file operations
▲*
▲*
▲* {{Javadoc:SE|package=java.sql|java/sql}}: [[Java Database Connectivity]] (JDBC)
* {{Javadoc:SE|package=java.awt|java/awt}}: basic hierarchy of packages for native GUI components
* {{Javadoc:SE|package=javax.swing|javax/swing}}: hierarchy of packages for platform-independent rich GUI components
== External links ==
* {{Javadoc:SE}}
{{compu-lang-stub}}
|