Documentation

The Java™ Tutorials
Hide TOC
Structure of the JNLP FileJNLP文件的结构
Trail: Deployment
Lesson: Deployment In-Depth
Section: Java Network Launch Protocol

Structure of the JNLP FileJNLP文件的结构

This topic describes the syntax of the Java Network Launch Protocol (JNLP) file for rich Internet applications (RIAs).本主题描述了富Internet应用程序(RIA)的Java网络启动协议(JNLP)文件的语法。

The following code snippet shows a sample JNLP file for a Java Web Start application:以下代码段显示了Java Web Start应用程序的示例JNLP文件:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href=""> <information> <title>Dynamic Tree Demo</title> <vendor>Dynamic Team</vendor> <icon href="sometree-icon.jpg"/> <offline-allowed/> </information> <resources> <!-- Application Resources --> <j2se version="1.6+" href=
           "http://java.sun.com/products/autodl/j2se"/> <jar href="DynamicTreeDemo.jar"
            main="true" /> </resources> <application-desc
         name="Dynamic Tree Demo Application"
         main-class="webstartComponentArch.DynamicTreeApplication"
         width="300"
         height="300"> </application-desc> <update check="background"/>
</jnlp>

The following table describes the elements and attributes commonly used in JNLP files. 下表描述了JNLP文件中常用的元素和属性。Click the parent link to view an element's parent.单击父级链接以查看元素的父级。


Note: This table does not include all possible contents of the JNLP file. 此表不包括JNLP文件的所有可能内容。For more information, see the Java Network Launching Protocol and API Specification Change Log. 有关更多信息,请参阅Java网络启动协议和API规范更改日志
Commonly Used Elements and Attributes in a JNLP fileJNLP文件中常用的元素和属性

Element要素

Attributes属性

Description描述

Since自从

Required要求的

jnlp


The topmost xml element for a JNLP file.JNLP文件的最顶层xml元素。

1.0

Yes


spec

Value of the attribute can be 1.0, 1.5, or 6.0, or can use wildcards such as 1.0+. 该属性的值可以是1.0、1.5或6.0,也可以使用通配符,如1.0+。It denotes the minimum version of the JNLP Specification that this JNLP file can work with.它表示此JNLP文件可以使用的JNLP规范的最低版本。

1.0



codebase

The base location for all relative URLs specified in href attributes in the JNLP file.JNLP文件中href属性中指定的所有相对URL的基本位置。

1.0



href

The URL of the JNLP file itself.JNLP文件本身的URL。

1.0



version

The version of the RIA being launched, as well as the version of the JNLP file itself.正在启动的RIA版本,以及JNLP文件本身的版本。

1.0


     information parent


Contains other elements that describe the RIA and its source.包含描述RIA及其来源的其他元素。

1.0

Yes


os

The operating system for which this information element should be considered.应考虑此信息元素的操作系统。

1.5.0



arch

The architecture for which this information element should be considered.应考虑此信息元素的体系结构。

1.5.0



platform

The platform for which this information element should be considered.应考虑此信息元素的平台。

1.5.0



locale

The locale for which this information element should be considered.应考虑此信息元素的区域设置。

1.5.0


         title parent


The title of the RIA.RIA的标题。

1.0

Yes

         vendor parent


The provider of the RIA.RIA的提供者。

1.0

Yes

         homepage parent


The homepage of the RIA.RIA的主页。

1.0



href

A URL pointing to where more information about this RIA can be found.指向可在何处找到有关此RIA的更多信息的URL。

1.0

Yes

         description parent


A short statement describing the RIA.描述RIA的简短声明。

1.0



kind

An indicator as to the type of description. Legal values are one-line, short, and tooltip.描述类型的指示符。合法值为单行、短值和工具提示。

1.0


         icon parent


An icon that can be used to identify the RIA to the user.可用于向用户标识RIA的图标。

1.0



href

A URL pointing to the icon file. Can be in one of the following formats: gif, jpg, png, ico.指向图标文件的URL。可以采用以下格式之一:gif、jpg、png、ico。

1.0

Yes


kind

Indicates the suggested use of the icon, can be: default, selected, disabled, rollover, splash, or shortcut.指示建议使用的图标,可以是:默认、选定、禁用、滚动、飞溅或快捷方式。

1.0



width

Can be used to indicate the resolution of the image.可用于指示图像的分辨率。

1.0



height

Can be used to indicate the resolution of the image.可用于指示图像的分辨率。

1.0



depth

Can be used to indicate the resolution of the image.可用于指示图像的分辨率。

1.0


         offline-allowed parent


Indicates that this RIA can operate when the client system is disconnected from the network.指示当客户端系统与网络断开连接时,此RIA可以运行。

1.0


         shortcut parent


Can be used to indicate the RIA's preferences for desktop integration.可用于指示RIA对桌面集成的首选项。

1.5.0



online

Can be used to describe the RIA's preference for creating a shortcut to run online or offline.可以用来描述RIA创建在线或离线运行的快捷方式的偏好。

1.5.0


         desktop parent


Can be used to indicate the RIA's preference for putting a shortcut on the user's desktop.可用于指示RIA在用户桌面上放置快捷方式的偏好。

1.5.0


         menu parent


Can be used to indicate the RIA's preference for putting a menu item in the user's start menus.可用于指示RIA在用户开始菜单中放置菜单项的首选项。

1.5.0



sub-menu

Can be used to indicate the RIA's preference for where to place the menu item.可用于指示RIA对菜单项放置位置的偏好。

1.5.0


         association parent


Can be used to hint to the JNLP client that the RIA wants to be registered with the operating system as the primary handler of certain extensions and a certain mime-type. 可以用于向JNLP客户端提示RIA希望在操作系统中注册为特定扩展和特定mime类型的主处理程序。If this element is included, either the offline-allowed element must also be included, or the href attribute must be set for the jnlp element.如果包含此元素,则还必须包含脱机允许的元素,或者必须为jnlp元素设置href属性。

1.5.0



extensions

A list of file extensions (separated by spaces) that the RIA requests it be registered to handle.RIA请求注册以处理的文件扩展名列表(用空格分隔)。

1.5.0



mime-type

The mime-type that the RIA requests it be registered to handle.RIA请求注册以处理的mime类型。

1.5.0


         related-content parent


An additional piece of related content that can be integrated with the RIA.可以与RIA集成的其他相关内容。

1.5.0



href

A URL pointing to the related content.指向相关内容的URL。

1.5.0

Yes

    update parent


The preferences for how RIA updates should be handled by the JNLP client.JNLP客户端应如何处理RIA更新的首选项。

1.6.0



check

The preference for when the JNLP client should check for updates. Value can be always, timeout, or background..JNLP客户端应检查更新的首选项。值可以是always、timeout或background……

1.6.0



policy

The preference for how the JNLP client should handle a RIA update when a new version is available before the RIA is launched. 当新版本在RIA启动之前可用时,JNLP客户端应如何处理RIA更新的首选项。Values can be always, prompt-update, or prompt-run.值可以是“始终”、“提示更新”或“提示运行”。

1.6.0





1.0


    security parent


Can be used to request enhanced permissions. 可用于请求增强权限。If this element is not included, the application is run in the security sandbox.如果未包含此元素,则应用程序将在安全沙盒中运行。

1.0


         all-permissions parent


Requests that the RIA be run with all permissions.请求以所有权限运行RIA。

1.0


         j2ee-application-client-permissions parent


Requests that the RIA be run with a permission set that meets the security specifications of the J2EE application client environment.请求使用满足J2EE应用程序客户端环境安全规范的权限集运行RIA。

1.0


    resources parent


Describes all the resources that are needed for the RIA.描述RIA所需的所有资源。

1.0

Yes


os

The operating system for which the resources element should be considered.应考虑资源元素的操作系统。

1.0



arch

The architecture for which the resources element should be considered.应考虑资源元素的体系结构。

1.0



locale

The locales for which the resources element should be considered.应该为其考虑resources元素的区域设置。



         java or j2se parent


Versions of Java software to run the RIA with.用于运行RIA的Java软件版本。

1.6.0 (java)



version

Ordered list of version ranges to use.要使用的版本范围的有序列表。

1.0

Yes


href

The URL denoting the supplier of this version of Java software, and from where it can be downloaded.表示此版本Java软件供应商的URL,以及可以从何处下载。

1.0



java-vm-args

An additional set of standard and non-standard virtual machine arguments that the RIA would prefer the JNLP client use when launching the JRE software.RIA希望JNLP客户端在启动JRE软件时使用的另一组标准和非标准虚拟机参数。

1.0



initial-heap-size

The initial size of the Java heap.Java堆的初始大小。

1.0



max-heap-size

The maximum size of the Java heap.Java堆的最大大小。

1.0


         jar parent


A JAR file that is part of the RIA's classpath.作为RIA类路径一部分的JAR文件。

1.0

Yes


href

The URL of the JAR file.JAR文件的URL。

1.0

Yes


version

The requested version of the JAR file. Requires using the version-based download protocol请求的JAR文件版本。需要使用基于版本的下载协议

1.0



main

Indicates if this JAR file contains the class containing the main method of the RIA.指示此JAR文件是否包含包含RIAmain方法的类。

1.0



download

Indicates that this JAR file can be downloaded lazily, or when needed.指示此JAR文件可以延迟下载,或在需要时下载。

1.0



size

The downloadable size of the JAR file in bytes.JAR文件的可下载大小(字节)。

1.0



part

Can be used to group resources together so that they are downloaded at the same time.可用于将资源分组,以便同时下载。

1.0


         nativelib parent


A JAR file that contains native libraries in its root directory.在其根目录中包含本机库的JAR文件。

1.0



href

The URL of the JAR file.JAR文件的URL。

1.0

Yes


version

The requested version of the JAR file. 请求的JAR文件版本。Requires using the version-based download protocol需要使用基于版本的下载协议

1.0



download

Can be used to indicate this JAR file can be downloaded lazily.可用于指示此JAR文件可以延迟下载。

1.0



size

The downloadable size of the JAR file in bytes.JAR文件的可下载大小(字节)。

1.0



part

Can be used to group resources together so they will be downloaded at the same time.可用于将资源分组,以便同时下载。

1.0


         extension parent


A pointer to an additional component-desc or installer-desc to be used with this RIA.指向要与此RIA一起使用的其他组件描述或安装程序描述的指针。

1.0



href

The URL to the additional extension JNLP file.附加扩展名JNLP文件的URL。

1.0

Yes


version

The version of the additional extension JNLP file.附加扩展名JNLP文件的版本。

1.0



name

The name of the additional extension JNLP file附加扩展名JNLP文件的名称

1.0


             ext-download parent


Can be used in an extension element to denote the parts contained in a component-extension.可以在扩展元素中使用,以表示组件扩展中包含的零件。

1.0



ext-part

The name of a part that can be expected to be found in the extension.可以在扩展中找到的零件的名称。

1.0

Yes


download

Can be used to indicate this extension can be downloaded eagerly or lazily.可用于指示此扩展可以急切地或懒散地下载。

1.0



part

Denotes the name of a part in this JNLP file in which to include the extension.表示此JNLP文件中要包含扩展名的部件的名称。

1.0


         package parent


Can be used to indicate to the JNLP client which packages are implemented in which JAR files.可以用于向JNLP客户端指示哪些包在哪些JAR文件中实现。

1.0



name

Package name contained in the JAR files of the given part.给定部件的JAR文件中包含的包名称。

1.0

Yes


part

Part name containing the JAR files that include the given package name.包含包含给定包名的JAR文件的部件名。

1.0

Yes


recursive

Can be used to indicate that all package names, beginning with the given name, can be found in the given part.可用于指示在给定部分中可以找到以给定名称开头的所有包名称。

1.0


         property parent


Defines a system property that will be available through the System.getProperty and System.getProperties methods.定义可通过System.getPropertySystem.getProperties方法使用的系统属性。

1.0



name

Name of the system property.系统属性的名称。

1.0

Yes


value

Value of the system property.系统属性的值。

1.0

Yes



Note: A JNLP file must contain one of the following: application-desc, applet-desc, component-desc, or installer-desc.注意:JNLP文件必须包含以下内容之一:application desc、applet desc、component desc或installer-desc。

1.0

Yes

    application-desc parent


Denotes this is the JNLP file for an application.表示这是应用程序的JNLP文件。

1.0



main-class

The name of the class containing the public static void main(String[]) method of the application.包含应用程序的public static void main(String[])方法的类的名称。

1.0

Yes

         argument parent


Each argument contains (in order) an additional argument to be passed to the main method.每个参数都包含(按顺序)要传递给main方法的附加参数

1.0


    applet-desc parent


Denotes this is the JNLP file for an applet.表示这是小程序的JNLP文件。

1.0



main-class

The name of the main applet class.主小程序类的名称。

1.0

Yes


documentbase

The document base for the applet as a URL.小程序的文档库作为URL。

1.0



name

Name of the applet.小程序的名称。

1.0

Yes


width

The width of the applet in pixels.小程序的宽度(以像素为单位)。

1.0

Yes


height

The height of the applet in pixels.小程序的高度(像素)。

1.0

Yes

         param parent


A set of parameters that can be passed to the applet.可以传递给小程序的一组参数。

1.0



name

The name of this parameter.此参数的名称。

1.0

Yes


value

The value of this parameter.此参数的值。

1.0

Yes

    component-desc parent


Denotes this is the JNLP file for a component extension.表示这是组件扩展名的JNLP文件。

1.0


    installer-desc parent


Denotes this is the JNLP file for an installed extension.表示这是已安装扩展名的JNLP文件。

1.0



main-class

The name of the class containing the public static void main(String[]) method of the installer.包含安装程序的公共静态public static void main(String[])方法的类的名称。

1.0

Yes

Encoding JNLP Files编码JNLP文件

Java Web Start software supports encoding of JNLP files in any character encoding supported by the Java platform. Java Web Start软件支持在Java平台支持的任何字符编码中对JNLP文件进行编码。For more information about character encoding in the Java platform, see the Supported Encodings Guide. 有关Java平台中字符编码的更多信息,请参阅《支持的编码指南》To encode a JNLP file, specify an encoding in the XML prolog of that file. 要对JNLP文件进行编码,请在该文件的XML prolog中指定编码。For example, the following line indicates that the JNLP file is encoded in UTF-16.例如,下面的行指示JNLP文件是以UTF-16编码的。

<?xml version="1.0" encoding="utf-16"?>

Note: The XML prolog itself must be UTF-8-encoded. XML prolog本身必须是UTF-8编码的。

Previous page: Java Network Launch Protocol
Next page: Deployment Best Practices