Name

JavaPackage: JavaScript representation of a Java package — LiveConnect

Synopsis

package.package_name  // Refers to another JavaPackage
package.class_name    // Refers to a JavaClass object

Properties

The properties of a JavaPackage object are the names of the JavaPackage objects and JavaClass objects that it contains. These properties are different for each individual JavaPackage. Note that it is not possible to use the JavaScript for/in loop to iterate over the list of property names of a Package object. Consult a Java reference manual to determine the packages and classes contained within any given package.

Description

The JavaPackage object is a JavaScript representation of a Java package. A package in Java is a collection of related classes. In JavaScript, a JavaPackage can contain classes (represented by the JavaClass object) and other JavaPackage objects.

The global object has a JavaPackage property named java that represents the java.* package hierarchy. This JavaPackage object defines properties that refer to other JavaPackage objects. For example, java.lang and java.net refer to the java.lang and http://java.net packages. The java.awt JavaPackage contains properties named Frame and Button, which are references to JavaClass objects and represent the classes java.awt.Frame and java.awt.Button.

The global object also defines a property named Packages, which is the root JavaPackage whose properties refer to the roots of all known package hierarchies. For example, the expression ...

Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.