java web start 1.0 developers guide (3)
发表于:2007-07-01来源:作者:点击数:
标签:
Optional width and height attributes can be used to indicate the size of the images. offline-allowed element: The optional offline-allowed element indicates if the application can be launched offline. Applications that are not marked offlin
Optional width and height attributes can be used to indicate the size of the images.
offline-allowed element: The optional offline-allowed element indicates if the application can be launched offline.
Applications that are not marked offline in the JNLP file will not be able to be launched through the Application Manager, if the offline checkbox is checked. The default is that an application only works if the client system is online.
The Security Element
Each application is, by default, run in a restricted execution environment, similar to the Applet sandbox. The security element can be used to request unrestricted a
clearcase/" target="_blank" >ccess.
If the all-permissions element is specified, the application will have full access to the client machine and local
.network. If an application requested full access, then all JAR files must be signed. The user will be prompted to accept the certificate the first time the application is launched.
The Resources Element
The resources element is used to specify all the resources, such as Java class files, native libraries, and system properties, that are part of the application. A resource definition can be restricted to a specific operating system, architecture, or locale using the os, arch, and locale attributes.
The resources element has 6 different possible subelements: jar, nativelib, j2se, property, package, and extension. The package and extension elements are not discussed in this developer@#s guide. See specification for details.
A jar element specifies a JAR file that is part of the application@#s classpath. For example:
<jar href="myjar.jar"/>
The jar file will be loaded into the JVM using a ClassLoader object. The jar file will typically contain Java classes that contain the code for the particular application, but can also contain other resources, such as icons and configuration files, that are available through the getResource mechanism.
A nativelib element specifies a JAR file that contains native libraries. For example:
<nativelib href="lib/
windows/corelib.jar"/>
The JNLP Client must ensure that each file entry in the root directory of the JAR file (i.e., /) can be loaded into the running process using the System.loadLibrary method. Each entry must contain a platform-dependent shared library with the correct naming convention, e.g., *.dll on
Windows, or lib*.so on Solaris/
Linux. The application is responsible for doing the actual call to System.loadLibrary.
Native libraries would typically be included in a resources element that is guarded against a particular operating system and architecture. For example:
<resources os="SunOS" arch="sparc">
<nativelib href="lib/solaris/corelibs.jar"/>
</resource>
By default, jar and nativelib resources will be downloaded eagerly, i.e., they are downloaded and available locally to the JVM running the application before the application is launched. The jar and nativelib elements also allow a resource to be specified as lazy. This means that the resource does not necessarily need to be downloaded onto the client system before the application is launched.
The download attribute is used to control whether a resource is downloaded eagerly or lazily. For example:
<jar href="sound.jar" download="lazy"/>
<nativelib href="native-sound.jar" download="eager"/>
The j2se element specifies what Java 2 SE Runtime Environment (JRE) versions an application is supported on, as well as standard parameters to the Java Virtual Machine. Several JREs can be specified, which indicates a prioritized list of the supported JREs, with the most preferred version first. For example:
<j2se version="1.3" initial-heap-size="64m"/>
<j2se version="1.2"/>
The version attribute refers to, by default, a particular revision of the Java 2 platform. Current defined revisions are "1.2" and "1.3". The JNLP specification also allows specifying exact product versions, such as the Java 2 JRE 1.2.2-001 by Sun Microsystems, Inc.
The property element defines a system property that will be available through the System.getProperty and System.getProperties methods. It has two required attributes: name and value. For example:
<property name="key" value="overwritten"/>
The Application-Desc Element
The application element indicates that the JNLP file is launching an application (as opposed to an Applet). The application element has an optional attribute, main-class, which can be used to specify the name of the application@#s main class, i.e., the class that contains the public static void main(String argv[]) method where execution must begin.
The main-class attribute can be omitted, if the first JAR file specified in the JNLP File contains a manifest file containing the main class.
Arguments can be specified to the application be including one or more nested argument elements. For example:
<application-desc main-class="Main">
<argument>arg1</argument>
<argument>arg2</argument>
</application-desc>
The Applet-Desc Element
Java Web Start has support for launching Java Applets. This support provides easy migration of existing code to Java Web Start.
An Applet is launched using the applet-desc element instead of the application-desc element. For example:
<applet-desc
documentBase="http://..."
name="TimePilot"
main-class="TimePilot.TimePilotApp"
width="527"
height="428">
<param name="key1" value="value1"/>
<param name="key2" value="value2"/>
</applet-desc>
The JAR files that make up the Applet are described using the resources element as for applications. The documentBase must be provided explicitly since a JNLP file is not embedded in an HTML page. The rest of the attributes correspond to the respective HTML applet tag elements.
The main-class attribute is used instead of the code attribute. The main-class attribute is assigned the name of the Applet class (without the .class extension). This attribute can be omitted if the Applet class can be found from the Main-Class manifest entry in the main JAR file.
Note: Applets must be packaged in JAR files in order to work with Java Web Start.
原文转自:http://www.ltesting.net