array('UTF-8', 'en'), 'content' => array('index.html', 'Contents'), 'home' => array('index.html', 'Core JavaScript Reference'), 'this' => array('javpkg.html', 'JavaPackage'), 'prev' => array('javobj.html', 'JavaObject'), 'next' => array('math.html', 'Math'), 'toc' => array( array('preface.html', 'About this Book', 0), /* array('preface.html#1003152', 'New Features in this Release', 1), array('preface.html#1005135', 'What You Should Already Know', 1), array('preface.html#1003515', 'JavaScript Versions', 1), array('preface.html#1001692', 'Where to Find JavaScript Information', 1), array('preface.html#1001745', 'Document Conventions', 1), */ array('partobj.html', 'Part 1', 0), array('objintro.html', 'Chapter 1. Objects, Methods, and Properties', 0), array('array.html', 'Array', 1), array('boolean.html', 'Boolean', 1), array('date.html', 'Date', 1), array('function.html', 'Function', 1), array('java.html', 'java', 1), array('javarray.html', 'JavaArray', 1), array('javclass.html', 'JavaClass', 1), array('javobj.html', 'JavaObject', 1), array('javpkg.html', 'JavaPackage', 1), array('math.html', 'Math', 1), array('netscape.html', 'netscape', 1), array('number.html', 'Number', 1), array('object.html', 'Object', 1), array('packages.html', 'Packages', 1), array('regexp.html', 'RegExp', 1), array('string.html', 'String', 1), array('sun.html', 'sun', 1), array('toplev.html', 'Chapter 2. Top-Level Properties and Functions', 0), /* array('toplev.html#1120957', 'decodeURI', 1), array('toplev.html#1119005', 'decodeURIComponent', 1), array('toplev.html#1118346', 'encodeURI', 1), array('toplev.html#1115986', 'encodeURIComponent', 1), array('toplev.html#1063795', 'eval', 1), array('toplev.html#1063963', 'Infinity', 1), array('toplev.html#1063988', 'isFinite', 1), array('toplev.html#1064024', 'isNaN', 1), array('toplev.html#1064064', 'NaN', 1), array('toplev.html#1064092', 'Number', 1), array('toplev.html#1064132', 'parseFloat', 1), array('toplev.html#1064173', 'parseInt', 1), array('toplev.html#1064506', 'String', 1), array('toplev.html#1094680', 'undefined', 1), */ array('partlang.html', 'Part 2', 0), array('stmt.html', 'Chapter 3. Statements', 0), /* array('stmt.html#1081298', 'break', 1), array('stmt.html#1077887', 'const', 1), array('stmt.html#1078923', 'continue', 1), array('stmt.html#1037353', 'do...while', 1), array('stmt.html#1016648', 'export', 1), array('stmt.html#1004804', 'for', 1), array('stmt.html#1004815', 'for...in', 1), array('stmt.html#1004825', 'function', 1), array('stmt.html#1004833', 'if...else', 1), array('stmt.html#1082618', 'import', 1), array('stmt.html#1018088', 'label', 1), array('stmt.html#1004871', 'return', 1), array('stmt.html#1018610', 'switch', 1), array('stmt.html#1052196', 'throw', 1), array('stmt.html#1051663', 'try...catch', 1), array('stmt.html#1066604', 'var', 1), array('stmt.html#1004896', 'while', 1), array('stmt.html#1004910', 'with', 1), */ array('comment.html', 'Chapter 4. Comments', 0), /* array('comment.html#1066617', 'comment', 1), */ array('ops.html', 'Chapter 5. Operators', 0), /* array('ops.html#1042274', 'Assignment Operators', 1), array('ops.html#1060974', 'Comparison Operators', 1), array('ops.html#1050908', 'Using the Equality Operators', 2), array('ops.html#1042400', 'Arithmetic Operators', 1), array('ops.html#1042403', '% (Modulus)', 2), array('ops.html#1042412', '++ (Increment)', 2), array('ops.html#1042421', '-- (Decrement)', 2), array('ops.html#1042430', '- (Unary Negation)', 2), array('ops.html#1042437', 'Bitwise Operators', 1), array('ops.html#1042500', 'Bitwise Logical Operators', 2), array('ops.html#1042512', 'Bitwise Shift Operators', 2), array('ops.html#1044813', 'Logical Operators', 1), array('ops.html#1042582', 'String Operators', 1), array('ops.html#1042588', 'Special Operators', 1), array('ops.html#1045406', '?: (Conditional operator)', 2), array('ops.html#1045439', ', (Comma operator)', 2), array('ops.html#1045837', 'delete', 2), array('ops.html#1066344', 'function', 2), array('ops.html#1066286', 'in', 2), array('ops.html#1055015', 'instanceof', 2), array('ops.html#1055898', 'new', 2), array('ops.html#1043482', 'this', 2), array('ops.html#1042603', 'typeof', 2), array('ops.html#1042625', 'void', 2), */ array('partjava.html', 'Part 3. LiveConn', 0), array('classint.html', 'Chapter 6. Java Classes, Constructors, and Methods', 0), /* array('lcjsexc.html#1193143', 'JSException', 1), array('lcjsobj.html#1193143', 'JSObject', 1), */ array('partapp.html', 'Part 4', 0), array('keywords.html', 'Appendix A. Reserved Words', 0), array('deprecat.html', 'Appendix B. Deprecated Features', 0), array('ix.html#573', 'Index', 0) ))); manual_header(); ?>




JavaPackage

A JavaScript reference to a Java package.


Core object  

 

Implemented in  

JavaScript 1.1, NES 2.0  


Created by
A reference to the package name used with the Packages keyword:

Packages.JavaPackage

where JavaPackage is the name of the object's Java package. If the package is in the java, netscape, or sun packages, the Packages keyword is optional.


Description
In Java, a package is a collection of Java classes or other Java packages. For example, the netscape package contains the package netscape.javascript; the netscape.javascript package contains the classes JSObject and JSException.

In JavaScript, a JavaPackage is a reference to a Java package. For example, a reference to netscape is a JavaPackage. netscape.javascript is both a JavaPackage and a property of the netscape JavaPackage.

A JavaClass object is a reference to one of the classes in a package, such as netscape.javascript.JSObject. The JavaPackage and JavaClass hierarchy reflect the Java package and class hierarchy.

Although the packages and classes contained in a JavaPackage are its properties, you cannot use a for...in statement to enumerate them as you can enumerate the properties of other objects.


Property Summary
The properties of a JavaPackage are the JavaClass objects and any other JavaPackage objects it contains.


Examples
Suppose the Redwood corporation uses the Java redwood package to contain various Java classes that it implements. The following code creates the JavaPackage red:

var red = Packages.redwood


See also
JavaArray, JavaClass, JavaObject, Packages