原文地址: http://mindprod.com/jgloss/jnlp.html

  • You are here :
  • home
  • Java Glossary
  • J words
  • JNLP
JNLP
Java Network Launching Protocol. A protocol for installing the JVM and Java apps. Sun has written a specific implementation of it called Java Web Start.

The Java Web Start entry will explain how to set up the *.jnlp to javaws.exe association in your browser and desktop.

JNLP Versions JNLP Validation
Sample JNLP 1.5 The XSD Schemas
Sample JNLP 1.6 The Validator Program
Icons DTD for JNLP
Off/line Snooping
JVM Versions Learning More
Multiple JNLP Files Links
JNLP Tokens  

JNLP Versions

JNLP comes in three versions. 1.0, 1.5 and 6.0.

New in version 1.5, JDK 1.5+:

  • splash image type.
  • shortcut, associations, related-content
  • js2e java-vm-args
  • os, arch, and platform
  • added ampersand (&) modifier to the version-range argument to allow compound versions.

New in Version 6.0, JDK 1.6+:

  • update and its args check and policy.
  • association now has description and icon.
  • java element to eventually replace j2se.

Sample JNLP 1.5

JNLP ( Java Network Launching Protocol) is the specification. You create an XML specification file, e.g. esper.jnlp that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<!-- example JNLP file, not totally realistic -->
<!-- no official DOCTYPE for 1.5 -->
<!-- where the jnlp file lives on the web -->
<jnlp spec="1.5+" codebase="http://www.mindprod.com/webstarts" href="esper.jnlp" version ="1.9">
<information>
<title>Esperanta Tradukilo Vortope 1.9</title>
<vendor>Canadian Mind Products</vendor>
<homepage href="webstart/esper.html" />
<description>Word for word Esperanto to/from English translator.</description>
<description kind="short">Looks up words on local and Internet Esperanto dictionaries.</description>
<!-- hover help for this app. Tradukilo means translating tool in Esperanto -->
<description kind="tooltip">Tradukilo</description>
<!-- gif or jpg only, no pngs in 1.5. Transparency does not work. Rectangular icons will be badly stretched. -->
<!-- relative to codebase -->
<icon href="../images/espericon64.gif" width="64" height="64" kind="default" />
<icon href="../splash.gif" kind="splash" />
<!-- allow app to run without Internet access -->
<offline-allowed />
<!-- request that the JAWS app be hooked up as the official OS handler of a given file type -->
<!-- note the plural extensions, but always a single value -->
<association mime-type="application/rtf" extensions="rtf" />
<association mime-type="image/wavelet" extensions="wi" />
<!-- hints for setting up shortcuts -->
<!-- Prefer a shortcut for online operation -->
<shortcut online="true">
<!-- create desktop shortcut -->
<desktop />
<!-- create menu item for this app under the major heading Esperanto -->
<menu submenu="Esperanto" />
</shortcut>
</information>
<security>
<all-permissions />
</security>
<resources>
<!-- Acceptable JVMs in preferred order, best first -->
<!-- Sun JVM -->
<j2se version="1.6.0_14" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<j2se version="1.6+"     href="http://java.sun.com/products/autodl/j2se" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<!-- allow any vendor -->
<j2se version="1.6+"     java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<j2se version="1.5+"     href="http://java.sun.com/products/autodl/j2se" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<!-- allow any vendor -->
<j2se version="1.5+"     java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<!-- application code, load before launch. JNLP 1.6 main="true" indicates jar with main class -->
<jar href="esper.jar" main="true" download="eager" size="99999" />
<!-- data dictionaries in compressed form, load as needed.  -->
<jar href="dicts.jar" main="false" download="lazy" size="99999" />
<!-- aux JNLP to describe the installer -->
<extension name="Installer" href="esperinstaller.jnlp"/>
<!-- set a -D system property -->
<property name="flavour" value="strawberry" />
</resources>
<!-- JNI native Sun .so code -->
<resources os="SunOS" arch="sparc">
<!-- relative to codebase -->
<nativelib href="lib/solaris/corelibs.jar" />
</resources>
<!-- JNI native Windows .dll code -->
<resources os="Windows" arch="x86">
<!-- relative to codebase -->
nativelib href="lib/windows/corelibs.jar" />
</resources>
<!-- application class with main method -->
<application-desc main-class="com.mindprod.esper.Esperanto">
<!-- command line arguments -->
<argument>Esperanto</argument>
<argument>English</argument>
</application-desc>
<!-- <applet-desc would go here for applet -->
<!-- code run once on install to unpack dicts.jar as part of one-time install -->
<!-- this has to go in a separate JNLP file from application-desc. -->
<installer-desc main-class="com.mindprod.esper.Installer" />
</jnlp>

Sample JNLP 1.6

Here is a sample JNLP 1.6 file: 
 
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not edit! last regenerated 2009-05-28 19:29 PDT by ReplicatorSender -->
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN" "http://java.sun.com/dtd/JNLP-6.0.dtd">
<jnlp spec="6.0+" codebase="http://mindprod.com/replicator" href="replicatorreceiverwebsite.jnlp" version="10.3">
<information>
<title>The Replicator 10.3 via website</title>
<vendor>Canadian Mind Products</vendor>
<homepage href="webstart/replicator.html" />
<description>Replicates files via website. Also keeps them up to date efficiently.</description>
<description kind="short">Replicates files via website.</description>
<description kind="one-line">Replicates files via website.</description>
<description kind="tooltip">the Replicator</description>
<!-- relative to codebase, need copy in same dir as jar, and jnlp file. -->
<icon href="replicator.icon64.png" width="64" height="64" kind="default" />
<icon href="replicator.splash.png" width="128" height="128" kind="splash" />
<!-- online only -->
<!-- create desktop shortcut to run the Replicator -->
<shortcut online="true">
<desktop />
<menu submenu="The Replicator" />
</shortcut>
</information>
<security>
<all-permissions />
</security>
<update check="always" policy="always" />
<resources>
<!-- requires 1.6 -->
<!-- Sun JVM -->
<java version="1.6.0_14" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<java version="1.6+" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<!-- any vendor -->
<java version="1.6+" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<!-- application code, download jar before we start. -->
<jar href="replicator.jar" main="true" download="eager" size="81920" />
<!-- set -D system properties -->
<property name="VIA" value="website" />
<property name="PROJECT_NAME" value="Mindprod.com" />
<property name="UNIQUE_PROJECT_NAME" value="com.mindprod.replicator" />
<property name="SUGGESTED_RECEIVER_BASE_DIR" value="C:/mindprod" />
<property name="SUGGESTED_RECEIVER_ZIP_STAGING_DIR" value="C:/mpstaging" />
<property name="WEBSITE_ZIP_URL" value="http://mindprod.com/replicator" />
<property name="SUGGESTED_LAN_ZIP_URL" value="http://mindprod.com/replicator" />
<property name="KEEP_ZIPS" value="false" />
<property name="UNPACK_ZIPS" value="true" />
<property name="AUTHENTICATION" value="none" />
<property name="DEBUGGING" value="true" />
</resources>
<!-- application class with main method -->
<application-desc main-class="com.mindprod.replicator.Replicator" />
</jnlp>

 

Note the use of <java instead of <j2se and <update check="always" policy="always" />. 

The ordering of the sections matters. You must do them in the order jnlp, information, security, update, resources, application-desc, applet-desc, component-desc, installer-desc. 

Within the resources sections, order is again important: java, j2se, jar, nativelib, extension, property, package. 

You nest <java inside <resources. However, you can nest another <resources inside the <java to describe the resources to use for that JVM only. 

Icons


Unfortunately Java Web Start, prior to version 1.6, does not support *.png files for the jnlp <icon image, just *.gif and *.jpg. *.pngs are supported in JDK 1.6. It is best to use a 64 × 64 icon. Unlike *.ico files, you may not specify multiple resolutions. If you used the *.png feature, it would cut off the many users still on Java 1.5. There is no support for *.ico files since they are Windows proprietary, and JWS apps are multi-platform. Note that this image is not in the jar. It has to be downloadable separately before the jar is. 

Off/line


If the app needs to be online to execute, remove the <offline-allowed/> from the information section. Beware, some websites erroneously document the parameter as <allow-offline/>. 

 

JVM Versions


<j2se version="1.3+" /> Does not mean that JDK version 1.3 or higher will be just fine. It means that any 1.3 version will do except a beta or ea. It does not imply a 1.4 will do. Others claim it does. I have not performed the experiments. To be safe, I insert multiple lines like this: 

 


<!-- Acceptable JVMs in preferred order, best first -->
<!-- means version 1.6 or higher, Sun JVM. However, I am unsure if 1.6.0_04-beta would match. -->
<j2se version="1.6+"     java-vm-args="-ea" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="128m" max-heap-size="512m" />
<!-- means version 1.6 or higher, any vendor -->
<j2se version="1.6+"     java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<!-- means any version beginning with 1.6, Sun JVM -->
<j2se version="1.6*"     java-vm-args="-ea" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="128m" max-heap-size="512m" />
<!-- means version 1.6.0_04 precisely, Sun JVM -->
<j2se version="1.6.0_04" java-vm-args="-ea" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="128m" max-heap-size="512m" />
<j2se version="1.5+"     java-vm-args="-ea" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="128m" max-heap-size="512m" />
<j2se version="1.4.2+"   java-vm-args="-ea" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="128m" max-heap-size="512m" />
<j2se version="1.3+"     java-vm-args="-ea" href="http://java.sun.com/products/autodl/j2se" initial-heap-size="128m" max-heap-size="512m" />

 

Every time Sun releases a new JRE, you need to add it to all your JNLP files if you want your clients to be able to access your web start apps with it. 


Multiple JNLP files

There are at least two situation where you might use two JNLP files for a single application: 
  1. When you have an installer. It needs its own separate JNLP file.
  2. When some jars are signed with one certificate and others with another. You need an JNLP file for each different certificate and its jars.
You chain the secondary JNLP off the main JNLP with a line after the <jar: 
<!-- chaining off an auxiliary jnlp file from the main one --><extension name="Installer" href="esperinstaller.jnlp"/>

JNLP Tokens

There are three magic tokens you can use in field names. They will be replaced when the jnlp script is executed. Unfortunately, I have not been able to discover out what strings they generate: $$codebase, $$context and $$name. I suspect codebase="$$codebase" means use the directory where you found the jnlp file as the codebase. $$name might be the name of the jnlp file.

JNLP Validation

You can check that your JNLP file is correctly formed using an XSD Schema originally from Vampqh. You must copy the JNLP 1.0 XSD schema posted below into the current directory as file jnlp1.xsd or jnlp6.xsd then run the Java validation posted below with: 
rem Validate a JNLP filejava.exe ValidateJNLP jnlp6.xsd C:/mydir/myapp.jnlp

 

The XSD Schemas


This JNLP 1.0 schema originaly came from Vampqh. I have modified it slightly. 

 


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Schema for a JNLP 1.0 -->
<xs:element name="jnlp" type="jnlpType"/>
<xs:complexType name="jnlpType">
<xs:sequence>
<xs:element name="information" type="informationType" maxOccurs="unbounded"/>
<xs:element name="security"    type="securityType"    minOccurs="0"/>
<xs:element name="resources"   type="resourcesType"   minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:element name="application-desc" type="applicationDescType"/>
<xs:element name="applet-desc"      type="appletDescType"/>
<xs:element name="component-desc"   type="xs:string"/>
<xs:element name="installer-desc"   type="xs:string"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="spec"     type="xs:string" use="optional"/>
<xs:attribute name="version"  type="xs:string" use="optional"/>
<xs:attribute name="codebase" type="xs:anyURI" use="optional"/>
<xs:attribute name="href"     type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="informationType">
<xs:sequence>
<xs:element name="title"           type="xs:string"      minOccurs="0"/>
<xs:element name="vendor"          type="xs:string"      minOccurs="0"/>
<xs:element name="homepage"        type="homepageType"    minOccurs="0"/>
<xs:element name="description"     type="descriptionType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="icon"            type="iconType"        minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="offline-allowed" type="xs:string"      minOccurs="0"/>
</xs:sequence>
<xs:attribute name="locale"  type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="homepageType">
<xs:attribute name="href"    type="xs:anyURI" use="required"/>
</xs:complexType>
<xs:simpleType name="descriptionKindType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="one-line"/>
<xs:enumeration value="short"/>
<xs:enumeration value="tooltip"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="descriptionType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="kind"    type="descriptionKindType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="iconKindType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="default"/>
<xs:enumeration value="selected"/>
<xs:enumeration value="disabled"/>
<xs:enumeration value="rollover"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="iconType">
<xs:attribute name="href"    type="xs:anyURI" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="width"   type="xs:positiveInteger" use="optional"/>
<xs:attribute name="height"  type="xs:positiveInteger" use="optional"/>
<xs:attribute name="kind"    type="iconKindType" use="optional"/>
<xs:attribute name="depth"   type="xs:positiveInteger" use="optional"/>
<xs:attribute name="size"    type="xs:positiveInteger" use="optional"/>
</xs:complexType>
<xs:complexType name="securityType">
<xs:sequence>
<xs:element name="all-permissions"  type="xs:string"  minOccurs="0"/>
<xs:element name="j2ee-application-client-permissions" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="resourcesType">
<xs:sequence>
<xs:element name="j2se"      type="j2seType"      minOccurs="0" maxOccurs="unbounded" />
<xs:element name="jar"       type="jarType"       minOccurs="0" maxOccurs="unbounded" />
<xs:element name="nativelib" type="nativelibType" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="extension" type="extensionType" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="property"  type="propertyType"  minOccurs="0" maxOccurs="unbounded" />
<xs:element name="package"   type="packageType"   minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="os"     type="xs:string" use="optional" />
<xs:attribute name="arch"   type="xs:string" use="optional" />
<xs:attribute name="locale" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="j2seType">
<xs:sequence>
<xs:element name="resources"  type="resourcesType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="version"           type="xs:string" use="required" />
<xs:attribute name="href"              type="xs:anyURI" use="optional" />
<xs:attribute name="initial-heap-size" type="xs:string" use="optional" />
<xs:attribute name="max-heap-size"     type="xs:string" use="optional" />
</xs:complexType>
<xs:simpleType name="booleanType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="downloadType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="jarType">
<xs:attribute name="href"     type="xs:anyURI"   use="required" />
<xs:attribute name="version"  type="xs:string"   use="optional" />
<xs:attribute name="main"     type="booleanType"  use="optional" />
<xs:attribute name="download" type="downloadType" use="optional" />
<xs:attribute name="size"     type="xs:string"   use="optional" />
<xs:attribute name="part"     type="xs:string"   use="optional" />
</xs:complexType>
<xs:complexType name="nativelibType">
<xs:attribute name="href"     type="xs:anyURI"   use="required" />
<xs:attribute name="version"  type="xs:string"   use="optional" />
<xs:attribute name="download" type="downloadType" use="optional" />
<xs:attribute name="size"     type="xs:string"   use="optional" />
<xs:attribute name="part"     type="xs:string"   use="optional" />
</xs:complexType>
<xs:complexType name="extensionType">
<xs:sequence>
<xs:element name="ext-download" type="extDownloadType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="version"  type="xs:string" use="optional" />
<xs:attribute name="name"     type="xs:string" use="optional" />
<xs:attribute name="href"     type="xs:anyURI" use="required" />
</xs:complexType>
<xs:complexType name="extDownloadType">
<xs:attribute name="ext-part"  type="xs:string"   use="required" />
<xs:attribute name="download"  type="downloadType" use="optional" />
<xs:attribute name="part"      type="xs:string"   use="optional" />
</xs:complexType>
<xs:complexType name="propertyType">
<xs:attribute name="name"   type="xs:string" use="required" />
<xs:attribute name="value"  type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="packageType">
<xs:attribute name="name"      type="xs:string"  use="required" />
<xs:attribute name="part"      type="xs:string"  use="required" />
<xs:attribute name="recursive" type="booleanType" use="optional" />
</xs:complexType>
<xs:complexType name="applicationDescType">
<xs:sequence>
<xs:element name="argument" type="xs:string"  minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="main-class" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="appletDescType">
<xs:sequence>
<xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="documentbase" type="xs:anyURI" use="optional" />
<xs:attribute name="main-class"   type="xs:string" use="required" />
<xs:attribute name="name"         type="xs:string" use="required" />
<xs:attribute name="width"        type="xs:positiveInteger" use="required" />
<xs:attribute name="height"       type="xs:positiveInteger" use="required" />
</xs:complexType>
<xs:complexType name="paramType">
<xs:attribute name="name"   type="xs:string" use="required" />
<xs:attribute name="value"  type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="installerDescType">
<xs:attribute name="main-class" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>

 

 

This JNLP 1.5 schema was mechanically generated by Stylus Studio from the Sun JNLP DTD. I modified it slightly to allow both an application and installer. 


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Schema for a JNLP 5.0. -->
<!-- mechanically generated from DTD.  Needs tweaking, reorg and comments to make it more comprehensible -->
<xs:element name="jnlp">
<xs:complexType>
<xs:sequence>
<xs:element ref="information" maxOccurs="unbounded"/>
<xs:element ref="security" minOccurs="0" maxOccurs="1"/>
<xs:element ref="update" minOccurs="0" maxOccurs="1"/>
<xs:element ref="resources" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:element ref="application-desc"/>
<xs:element ref="applet-desc"/>
<xs:element ref="component-desc"/>
</xs:choice>
<xs:element ref="installer-desc" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="spec" type="xs:string" use="optional"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="codebase" type="xs:string" use="optional"/>
<xs:attribute name="href" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="information">
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
<xs:element ref="vendor"/>
<xs:element ref="homepage" minOccurs="0" maxOccurs="1"/>
<xs:element ref="description" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="icon" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="offline-allowed" minOccurs="0" maxOccurs="1"/>
<xs:element ref="shortcut" minOccurs="0" maxOccurs="1"/>
<xs:element ref="association" minOccurs="0" maxOccurs="1"/>
<xs:element ref="related-content" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="os" type="xs:string" use="optional"/>
<xs:attribute name="arch" type="xs:string" use="optional"/>
<xs:attribute name="platform" type="xs:string" use="optional"/>
<xs:attribute name="locale" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="title" type="xs:string">
</xs:element>
<xs:element name="vendor" type="xs:string">
</xs:element>
<xs:element name="homepage">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="description">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="kind" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="one-line"/>
<xs:enumeration value="short"/>
<xs:enumeration value="tooltip"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="icon">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="width" type="xs:string" use="optional"/>
<xs:attribute name="height" type="xs:string" use="optional"/>
<xs:attribute name="kind" type="xs:string" use="optional"/>
<xs:attribute name="depth" type="xs:string" use="optional"/>
<xs:attribute name="size" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="offline-allowed">
<xs:complexType/>
</xs:element>
<xs:element name="security">
<xs:complexType>
<xs:sequence>
<xs:element ref="all-permissions" minOccurs="0" maxOccurs="1"/>
<xs:element ref="j2ee-application-client-permissions" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="all-permissions">
<xs:complexType/>
</xs:element>
<xs:element name="j2ee-application-client-permissions">
<xs:complexType/>
</xs:element>
<xs:element name="update">
<xs:complexType>
<xs:attribute name="check" default="timeout">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="always"/>
<xs:enumeration value="timeout"/>
<xs:enumeration value="background"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="policy" default="always">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="always"/>
<xs:enumeration value="prompt-update"/>
<xs:enumeration value="prompt-run"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="resources">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="java"/>
<xs:element ref="j2se"/>
<xs:element ref="jar"/>
<xs:element ref="nativelib"/>
<xs:element ref="extension"/>
<xs:element ref="property"/>
<xs:element ref="package"/>
</xs:choice>
<xs:attribute name="os" type="xs:string" use="optional"/>
<xs:attribute name="arch" type="xs:string" use="optional"/>
<xs:attribute name="locale" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="java">
<xs:complexType>
<xs:sequence>
<xs:element ref="resources" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="href" type="xs:string" use="optional"/>
<xs:attribute name="initial-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="max-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="java-vm-args" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="j2se">
<xs:complexType>
<xs:sequence>
<xs:element ref="resources" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="href" type="xs:string" use="optional"/>
<xs:attribute name="initial-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="max-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="java-vm-args" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="jar">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="main" default="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="download" default="eager">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="size" type="xs:string" use="optional"/>
<xs:attribute name="part" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="nativelib">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="download" default="eager">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="size" type="xs:string" use="optional"/>
<xs:attribute name="part" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="extension">
<xs:complexType>
<xs:sequence>
<xs:element ref="ext-download" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="ext-download">
<xs:complexType>
<xs:attribute name="ext-part" type="xs:string" use="required"/>
<xs:attribute name="download" default="eager">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lazy"/>
<xs:enumeration value="eager"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="part" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="property">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="package">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="part" type="xs:string" use="required"/>
<xs:attribute name="recursive" default="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="application-desc">
<xs:complexType>
<xs:sequence>
<xs:element ref="argument" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="main-class" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="argument" type="xs:string">
</xs:element>
<xs:element name="applet-desc">
<xs:complexType>
<xs:sequence>
<xs:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="documentbase" type="xs:string" use="optional"/>
<xs:attribute name="main-class" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="width" type="xs:string" use="required"/>
<xs:attribute name="height" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="param">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="component-desc">
<xs:complexType/>
</xs:element>
<xs:element name="installer-desc">
<xs:complexType>
<xs:attribute name="main-class" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="shortcut">
<xs:complexType>
<xs:sequence>
<xs:element ref="desktop" minOccurs="0" maxOccurs="1"/>
<xs:element ref="menu" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="online" default="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="desktop">
<xs:complexType/>
</xs:element>
<xs:element name="menu">
<xs:complexType>
<xs:attribute name="submenu" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="association">
<xs:complexType>
<xs:sequence>
<xs:element ref="description" minOccurs="0" maxOccurs="1"/>
<xs:element ref="icon" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="extensions" type="xs:string" use="required"/>
<xs:attribute name="mime-type" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="related-content">
<xs:complexType>
<xs:sequence>
<xs:element ref="title" minOccurs="0" maxOccurs="1"/>
<xs:element ref="description" minOccurs="0" maxOccurs="1"/>
<xs:element ref="icon" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

 

 

This JNLP 1.6 schema was mechanically generated by Stylus Studio from the Sun JNLP DTD. I modified it slightly to correct two syntax errors in the DTD and to allow both an application and installer. 

 

 

 

 


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Schema for a JNLP 6.0 -->
<!-- mechanically generated from DTD.  Needs tweaking, reorg and comments to make it more comprehensible -->
<xs:element name="jnlp">
<xs:complexType>
<xs:sequence>
<xs:element ref="information" maxOccurs="unbounded"/>
<xs:element ref="security" minOccurs="0" maxOccurs="1"/>
<xs:element ref="update" minOccurs="0" maxOccurs="1"/>
<xs:element ref="resources" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:element ref="application-desc"/>
<xs:element ref="applet-desc"/>
<xs:element ref="component-desc"/>
<xs:element ref="installer-desc"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="spec" type="xs:string" use="optional"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="codebase" type="xs:string" use="optional"/>
<xs:attribute name="href" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="information">
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
<xs:element ref="vendor"/>
<xs:element ref="homepage" minOccurs="0" maxOccurs="1"/>
<xs:element ref="description" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="icon" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="offline-allowed" minOccurs="0" maxOccurs="1"/>
<xs:element ref="shortcut" minOccurs="0" maxOccurs="1"/>
<xs:element ref="association" minOccurs="0" maxOccurs="1"/>
<xs:element ref="related-content" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="os" type="xs:string" use="optional"/>
<xs:attribute name="arch" type="xs:string" use="optional"/>
<xs:attribute name="platform" type="xs:string" use="optional"/>
<xs:attribute name="locale" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="title" type="xs:string">
</xs:element>
<xs:element name="vendor" type="xs:string">
</xs:element>
<xs:element name="homepage">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="description">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="kind" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="one-line"/>
<xs:enumeration value="short"/>
<xs:enumeration value="tooltip"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="icon">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="width" type="xs:string" use="optional"/>
<xs:attribute name="height" type="xs:string" use="optional"/>
<xs:attribute name="kind" type="xs:string" use="optional"/>
<xs:attribute name="depth" type="xs:string" use="optional"/>
<xs:attribute name="size" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="offline-allowed">
<xs:complexType/>
</xs:element>
<xs:element name="security">
<xs:complexType>
<xs:sequence>
<xs:element ref="all-permissions" minOccurs="0" maxOccurs="1"/>
<xs:element ref="j2ee-application-client-permissions" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="all-permissions">
<xs:complexType/>
</xs:element>
<xs:element name="j2ee-application-client-permissions">
<xs:complexType/>
</xs:element>
<xs:element name="update">
<xs:complexType>
<xs:attribute name="check" default="timeout">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="always"/>
<xs:enumeration value="timeout"/>
<xs:enumeration value="background"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="policy" default="always">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="always"/>
<xs:enumeration value="prompt-update"/>
<xs:enumeration value="prompt-run"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="resources">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="java"/>
<xs:element ref="j2se"/>
<xs:element ref="jar"/>
<xs:element ref="nativelib"/>
<xs:element ref="extension"/>
<xs:element ref="property"/>
<xs:element ref="package"/>
</xs:choice>
<xs:attribute name="os" type="xs:string" use="optional"/>
<xs:attribute name="arch" type="xs:string" use="optional"/>
<xs:attribute name="locale" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="java">
<xs:complexType>
<xs:sequence>
<xs:element ref="resources" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="href" type="xs:string" use="optional"/>
<xs:attribute name="initial-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="max-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="java-vm-args" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="j2se">
<xs:complexType>
<xs:sequence>
<xs:element ref="resources" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="href" type="xs:string" use="optional"/>
<xs:attribute name="initial-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="max-heap-size" type="xs:string" use="optional"/>
<xs:attribute name="java-vm-args" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="jar">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="main" default="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="download" default="eager">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="size" type="xs:string" use="optional"/>
<xs:attribute name="part" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="nativelib">
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="download" default="eager">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="size" type="xs:string" use="optional"/>
<xs:attribute name="part" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="extension">
<xs:complexType>
<xs:sequence>
<xs:element ref="ext-download" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="optional"/>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="ext-download">
<xs:complexType>
<xs:attribute name="ext-part" type="xs:string" use="required"/>
<xs:attribute name="download" default="eager">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lazy"/>
<xs:enumeration value="eager"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="part" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="property">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="package">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="part" type="xs:string" use="required"/>
<xs:attribute name="recursive" default="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="application-desc">
<xs:complexType>
<xs:sequence>
<xs:element ref="argument" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="main-class" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="argument" type="xs:string">
</xs:element>
<xs:element name="applet-desc">
<xs:complexType>
<xs:sequence>
<xs:element ref="param" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="documentbase" type="xs:string" use="optional"/>
<xs:attribute name="main-class" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="width" type="xs:string" use="required"/>
<xs:attribute name="height" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="param">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="component-desc">
<xs:complexType/>
</xs:element>
<xs:element name="installer-desc">
<xs:complexType>
<xs:attribute name="main-class" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="shortcut">
<xs:complexType>
<xs:sequence>
<xs:element ref="desktop" minOccurs="0" maxOccurs="1"/>
<xs:element ref="menu" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="online" default="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="desktop">
<xs:complexType/>
</xs:element>
<xs:element name="menu">
<xs:complexType>
<xs:attribute name="submenu" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="association">
<xs:complexType>
<xs:sequence>
<xs:element ref="description" minOccurs="0" maxOccurs="1"/>
<xs:element ref="icon" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="extensions" type="xs:string" use="required"/>
<xs:attribute name="mime-type" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="related-content">
<xs:complexType>
<xs:sequence>
<xs:element ref="title" minOccurs="0" maxOccurs="1"/>
<xs:element ref="description" minOccurs="0" maxOccurs="1"/>
<xs:element ref="icon" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

 


// validating a JNLP document with an XSD schema
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import javax.xml.XMLConstants;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
  * Validate on JNLP file using the Vampqh JNLP XSD schema
  * Requires a copy of the Vampqh schema "jnlp1-xml-schema.xsd" version 1.0
  * or "jnlp6-xml-schema.xsd" version 6.0 in the current directory.
  */
public class ValidateJNLP
{/**
    * validate one jnlp file
    *
    * @param args first name of xsd schema,
    * second name of name of the jnlp file to validate,
    * e.g. E:/com/mindprod/affirm/affirm.jnlp
    */
public static void main ( String[] args )
{try
{// build an XSD-aware SchemaFactory
SchemaFactory schemaFactory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
// hook up mindless org.xml.sax.ErrorHandler implementation.
schemaFactory.setErrorHandler( new JNLPErrorHandler() );
// get the custom xsd schema describing the required format for my XML files.
Schema schemaXSD = schemaFactory.newSchema( new File ( args[0] ) );
// Create a Validator capable of validating JNLP files according to to the custom schema.
Validator validator = schemaXSD.newValidator();
// Create a generic XML parser.
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// parse the JNLP file on the command line purely as XML and get a DOM tree represenation.
Document document = parser.parse( new File( args[1] ));
// Validate the JNLP tree against the stricter XSD schema
validator.validate( new DOMSource( document ) );
}
catch ( Exception e )
{e.printStackTrace();
}
} // end main
} // end ValidateJNLP
class JNLPErrorHandler implements ErrorHandler
{/**
    * default contstructor
    */
public JNLPErrorHandler()
{}
/**
    * Receive notification of a warning.
    *
    * <p>SAX parsers will use this method to report conditions that
    * are not errors or fatal errors as defined by the XML
    * recommendation.  The default behaviour is to take no
    * action.</p>
    *
    * <p>The SAX parser must continue to provide normal parsing events
    * after invoking this method: it should still be possible for the
    * application to process the document through to the end.</p>
    *
    * <p>Filters may use this method to report other, non-XML warnings
    * as well.</p>
    *
    * @param exception The warning information encapsulated in a
    *                  SAX parse exception.
    * @exception org.xml.sax.SAXException Any SAX exception, possibly
    *            wrapping another exception.
    * @see org.xml.sax.SAXParseException
    */
public void warning (SAXParseException exception)
throws SAXException
{System.err.println( exception );
}
/**
    * Receive notification of a recoverable error.
    *
    * <p>This corresponds to the definition of "error" in section 1.2
    * of the W3C XML 1.0 Recommendation.  For example, a validating
    * parser would use this callback to report the violation of a
    * validity constraint.  The default behaviour is to take no
    * action.</p>
    *
    * <p>The SAX parser must continue to provide normal parsing
    * events after invoking this method: it should still be possible
    * for the application to process the document through to the end.
    * If the application cannot do so, then the parser should report
    * a fatal error even if the XML recommendation does not require
    * it to do so.</p>
    *
    * <p>Filters may use this method to report other, non-XML errors
    * as well.</p>
    *
    * @param exception The error information encapsulated in a
    *                  SAX parse exception.
    * @exception org.xml.sax.SAXException Any SAX exception, possibly
    *            wrapping another exception.
    * @see org.xml.sax.SAXParseException
    */
public  void error (SAXParseException exception)
throws SAXException
{System.err.println( exception );
}
/**
    * Receive notification of a non-recoverable error.
    *
    * <p><strong>There is an apparent contradiction between the
    * documentation for this method and the documentation for {@link
    * org.xml.sax.ContentHandler#endDocument}.  Until this ambiguity
    * is resolved in a future major release, clients should make no
    * assumptions about whether endDocument() will or will not be
    * invoked when the parser has reported a fatalError() or thrown
    * an exception.</strong></p>
    *
    * <p>This corresponds to the definition of "fatal error" in
    * section 1.2 of the W3C XML 1.0 Recommendation.  For example, a
    * parser would use this callback to report the violation of a
    * well-formedness constraint.</p>
    *
    * <p>The application must assume that the document is unusable
    * after the parser has invoked this method, and should continue
    * (if at all) only for the sake of collecting additional error
    * messages: in fact, SAX parsers are free to stop reporting any
    * other events once this method has been invoked.</p>
    *
    * @param exception The error information encapsulated in a
    *                  SAX parse exception.
    * @exception org.xml.sax.SAXException Any SAX exception, possibly
    *            wrapping another exception.
    * @see org.xml.sax.SAXParseException
    */
public  void fatalError (SAXParseException exception)
throws SAXException
{System.err.println( exception );
}
} // end JNLPErrorHandler

 


// validating a JNLP document with an XSD schema
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import javax.xml.XMLConstants;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
  * Validate on JNLP file using the Vampqh JNLP XSD schema
  * Requires a copy of the Vampqh schema "jnlp1-xml-schema.xsd" version 1.0
  * or "jnlp6-xml-schema.xsd" version 6.0 in the current directory.
  */
public class ValidateJNLP
{/**
    * validate one jnlp file
    *
    * @param args first name of xsd schema,
    * second name of name of the jnlp file to validate,
    * e.g. E:/com/mindprod/affirm/affirm.jnlp
    */
public static void main ( String[] args )
{try
{// build an XSD-aware SchemaFactory
SchemaFactory schemaFactory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
// hook up mindless org.xml.sax.ErrorHandler implementation.
schemaFactory.setErrorHandler( new JNLPErrorHandler() );
// get the custom xsd schema describing the required format for my XML files.
Schema schemaXSD = schemaFactory.newSchema( new File ( args[0] ) );
// Create a Validator capable of validating JNLP files according to to the custom schema.
Validator validator = schemaXSD.newValidator();
// Create a generic XML parser.
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// parse the JNLP file on the command line purely as XML and get a DOM tree represenation.
Document document = parser.parse( new File( args[1] ));
// Validate the JNLP tree against the stricter XSD schema
validator.validate( new DOMSource( document ) );
}
catch ( Exception e )
{e.printStackTrace();
}
} // end main
} // end ValidateJNLP
class JNLPErrorHandler implements ErrorHandler
{/**
    * default contstructor
    */
public JNLPErrorHandler()
{}
/**
    * Receive notification of a warning.
    *
    * <p>SAX parsers will use this method to report conditions that
    * are not errors or fatal errors as defined by the XML
    * recommendation.  The default behaviour is to take no
    * action.</p>
    *
    * <p>The SAX parser must continue to provide normal parsing events
    * after invoking this method: it should still be possible for the
    * application to process the document through to the end.</p>
    *
    * <p>Filters may use this method to report other, non-XML warnings
    * as well.</p>
    *
    * @param exception The warning information encapsulated in a
    *                  SAX parse exception.
    * @exception org.xml.sax.SAXException Any SAX exception, possibly
    *            wrapping another exception.
    * @see org.xml.sax.SAXParseException
    */
public void warning (SAXParseException exception)
throws SAXException
{System.err.println( exception );
}
/**
    * Receive notification of a recoverable error.
    *
    * <p>This corresponds to the definition of "error" in section 1.2
    * of the W3C XML 1.0 Recommendation.  For example, a validating
    * parser would use this callback to report the violation of a
    * validity constraint.  The default behaviour is to take no
    * action.</p>
    *
    * <p>The SAX parser must continue to provide normal parsing
    * events after invoking this method: it should still be possible
    * for the application to process the document through to the end.
    * If the application cannot do so, then the parser should report
    * a fatal error even if the XML recommendation does not require
    * it to do so.</p>
    *
    * <p>Filters may use this method to report other, non-XML errors
    * as well.</p>
    *
    * @param exception The error information encapsulated in a
    *                  SAX parse exception.
    * @exception org.xml.sax.SAXException Any SAX exception, possibly
    *            wrapping another exception.
    * @see org.xml.sax.SAXParseException
    */
public  void error (SAXParseException exception)
throws SAXException
{System.err.println( exception );
}
/**
    * Receive notification of a non-recoverable error.
    *
    * <p><strong>There is an apparent contradiction between the
    * documentation for this method and the documentation for {@link
    * org.xml.sax.ContentHandler#endDocument}.  Until this ambiguity
    * is resolved in a future major release, clients should make no
    * assumptions about whether endDocument() will or will not be
    * invoked when the parser has reported a fatalError() or thrown
    * an exception.</strong></p>
    *
    * <p>This corresponds to the definition of "fatal error" in
    * section 1.2 of the W3C XML 1.0 Recommendation.  For example, a
    * parser would use this callback to report the violation of a
    * well-formedness constraint.</p>
    *
    * <p>The application must assume that the document is unusable
    * after the parser has invoked this method, and should continue
    * (if at all) only for the sake of collecting additional error
    * messages: in fact, SAX parsers are free to stop reporting any
    * other events once this method has been invoked.</p>
    *
    * @param exception The error information encapsulated in a
    *                  SAX parse exception.
    * @exception org.xml.sax.SAXException Any SAX exception, possibly
    *            wrapping another exception.
    * @see org.xml.sax.SAXParseException
    */
public  void fatalError (SAXParseException exception)
throws SAXException
{System.err.println( exception );
}
} // end JNLPErrorHandler

 

 


 

Snooping

One way to learn JNLP tricks is to snoop on the JNLP files of other people’s applications. You can do that most easily by typing at the command prompt: 
rem jnlpview.bat viewing a JNLP file.javaws.exe -viewerrem then right click on the installed JWS app and click show JNLP file.

Learning More


Sun’s JDK Technote Guide on JNLP syntax : available:

  • on the web at java.sun.com
  • in the current JDK 1.6.0_13 on your local Windows J: drive.

Sun’s Product Info on JNLP Downloadable Specification

cooktop
DTD
JaNeLA: JNLP verifier
Java Web Start
Lopiqua JNLP quick reference
Validating JNLP with a DTD
XML: JNLP is a type of XML and thus uses XML editing and validation tools
XSD

<!-- DTD to describe a JNLP 5.0 file, don't correct the spelling error in the next line.-->
<!--
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Discriptor 1.5//EN" "http://java.sun.com/dtd/JNLP-1.5.dtd">
-->
<!--
The root element for the JNLP file.
-->
<!ELEMENT jnlp (information+, security?, resources*,
(application-desc | applet-desc | component-desc |
installer-desc))>
<!--
The spec attribute of the jnlp element specifies what
versions of the JNLP specification a particular JNLP file
works with. The default value is "1.0+".
-->
<!ATTLIST jnlp spec CDATA #IMPLIED>
<!--
The version attribute of the jnlp element specifies the
version of the application being launched, as well as the
version of the JNLP file itself.
-->
<!ATTLIST jnlp version CDATA #IMPLIED>
<!--
The codebase attribute of the jnlp element specifies the
codebase for the application. This is also used as the base
URL for all relative URLs in href attributes.
-->
<!ATTLIST jnlp codebase CDATA #IMPLIED>
<!--
The href attribute of the jnlp element contains the location
of the JNLP file as a URL.
-->
<!ATTLIST jnlp href CDATA #IMPLIED>
<!--
The information element contains various descriptive
information about the application being launched.
-->
<!ELEMENT information (title?, vendor?, homepage?,
description*, icon*,offline-allowed?, shortcut?,
association?, related-content*)>
<!--
The os attribute of the information element specifies for
which operating system this element should be considered.
-->
<!ATTLIST information os CDATA #IMPLIED>
<!--
The arch attribute of the information element specifies for
what architecure this element should be considered.
-->
<!ATTLIST information arch CDATA #IMPLIED>
<!--
The platform attribute of the information element specifies
for what platform this element should be considered.
-->
<!ATTLIST information platform CDATA #IMPLIED>
<!--
The locale attribute of the information element specifies the
locale for which this information element should be used.
-->
<!ATTLIST information locale CDATA #IMPLIED>
<!--
The title element contains the name of the application.
-->
<!ELEMENT title (#PCDATA)>
<!--
The vendor element contains the name of the vendor.
-->
<!ELEMENT vendor (#PCDATA)>
<!--
The homepage element contains a href to the homepage for the
application.
-->
<!ELEMENT homepage EMPTY>
<!--
The href attribute of the homepage element specifies the URL
for the homepage.
-->
<!ATTLIST homepage href CDATA #REQUIRED>
<!--
The description element contains a description of the
application.
-->
<!ELEMENT description (#PCDATA)>
<!--
The kind attribute for the description element indicates the
use of a description element. The values are: i) one-line,
for a one-line description, ii) short, for a one paragraph
description, and iii) tooltip, for a tool-tip description.
Longer descriptions should be put on a separate web page and
referred to using the homepage element.
-->
<!ATTLIST description kind (one-line | short | tooltip)
#IMPLIED>
<!--
The icon element describes an image for an application.
-->
<!ELEMENT icon EMPTY>
<!--
The href attribute of an icon contains a URL to a location on
the web containing an image file for an icon.
-->
<!ATTLIST icon href CDATA #REQUIRED>
<!--
The version attribute of an icon contains a string describing
the version of the image that is requested.
-->
<!ATTLIST icon version CDATA #IMPLIED>
<!--
The width attribute of the icon element describes the width
of the icon in pixels.
-->
<!ATTLIST icon width CDATA #IMPLIED>
<!--
The height attribute of the icon element describes the height
of the icon in pixels.
-->
<!ATTLIST icon height CDATA #IMPLIED>
<!--
The kind attribute of the icon element describes the use of
the icon.
-->
<!ATTLIST icon kind CDATA #IMPLIED>
<!--
The depth attribute of the icon element describes the color
depth of the image in bits-per-pixel. Common values will be
8, 16, or 24.
-->
<!ATTLIST icon depth CDATA #IMPLIED>
<!--
The size attribute of an icon element indicates the size of
an icon file in bytes.
-->
<!ATTLIST icon size CDATA #IMPLIED>
<!--
The offline-allowed element indicates if the application can
be launched offline. Default value (i.e., if the element is
not specified) is online.
-->
<!ELEMENT offline-allowed EMPTY>
<!--
The security element describes the security requirements of
the application.
-->
<!ELEMENT security (all-permissions?,
j2ee-application-client-permissions?)>
<!--
The all-permissions element indicates that the application
needs full access the the local system and network.
-->
<!ELEMENT all-permissions EMPTY>
<!--
The j2ee-application-client-permissions element indicates
that the application needs the set of permissions defined for
a J2EE application client.
-->
<!ELEMENT j2ee-application-client-permissions EMPTY>
<!--
The resources element contains an ordered set of resources
that constitutes an application.
-->
<!ELEMENT resources (j2se | jar | nativelib | extension |
property | package)*>
<!--
The os attribute of the resources element specifies for which
operating system this element should be considered.
-->
<!ATTLIST resources os CDATA #IMPLIED>
<!--
The arch attribute of the resources element specifies for
what platform this element should be considered.
-->
<!ATTLIST resources arch CDATA #IMPLIED>
<!--
The locale attribute of the resources element specifies for
which locales this element should be considered.
-->
<!ATTLIST resources locale CDATA #IMPLIED>
<!--
The j2se element describes a supported JRE version and an
optional resources element to be used by the particular JRE.
-->
<!ELEMENT j2se (resources*)>
<!--
The version attribute of the j2se element describes the
versions of the JRE that this application is supported on.
-->
<!ATTLIST j2se version CDATA #REQUIRED>
<!--
The href attribute of the j2se element specifies the location
where the JRE should be downloaded from.
-->
<!ATTLIST j2se href CDATA #IMPLIED>
<!--
The initial-heap-size attribute of the j2se element specifies
the initial size of the object heap.
-->
<!ATTLIST j2se initial-heap-size CDATA #IMPLIED>
<!--
The max-heap-size attribute of the j2se element specifies the
preferred maximum size of the object heap.
-->
<!ATTLIST j2se max-heap-size CDATA #IMPLIED>
<!--
The java-vm-args attribute of the j2se element specifies a
preferred set of virtual machine arguments to use when
launching java.
-->
<!ATTLIST j2se java-vm-args CDATA #IMPLIED>
<!--
The jar element describes a jar file resource.
-->
<!ELEMENT jar EMPTY>
<!--
The href attribute of the jar element contains the location
of a jar file as a URL.
-->
<!ATTLIST jar href CDATA #REQUIRED>
<!--
The version attribute of a jar element describes the version
of a particular JAR file that is requested.
-->
<!ATTLIST jar version CDATA #IMPLIED>
<!--
The main attribute of a jar element indicates whether this
element contains the main class.
-->
<!ATTLIST jar main (true|false) "false">
<!--
The download attribute of a jar element indicates if this
element must be downloaded before an application is launched
(eager), or not (lazy).
-->
<!ATTLIST jar download (eager | lazy) "eager">
<!--
The size attribute of a jar element indicates the size of a
JAR file in bytes.
-->
<!ATTLIST jar size CDATA #IMPLIED>
<!--
The part attribute of a jar element describes the name of the
group it belongs too.
-->
<!ATTLIST jar part CDATA #IMPLIED>
<!--
The nativelib element describes a resource containing native
files.
-->
<!ELEMENT nativelib EMPTY>
<!--
The href attribute of a nativelib element contains the
location of a nativelib file as a URL.
-->
<!ATTLIST nativelib href CDATA #REQUIRED>
<!--
The version attribute of a nativelib element describes the
version of a particular nativelib file that is requested.
-->
<!ATTLIST nativelib version CDATA #IMPLIED>
<!--
The download attribute of a nativelib element indicates if
this element must be downloaded before an application is
launched (eager), or not (lazy).
-->
<!ATTLIST nativelib download (eager | lazy) "eager">
<!--
The size attribute of a nativelib element indicates the size
of a nativelib file in bytes.
-->
<!ATTLIST nativelib size CDATA #IMPLIED>
<!--
The part attribute of a nativelib element describes the name
of the part it belongs to.
-->
<!ATTLIST nativelib part CDATA #IMPLIED>
<!--
The extension element describes an extension that is required
in order to run the application.
-->
<!ELEMENT extension (ext-download*)>
<!--
The version attribute of an extension element specifies the
version of the extension requested.
-->
<!ATTLIST extension version CDATA #IMPLIED>
<!--
The name attribute of an extension element specifies the name
of the extension.
-->
<!ATTLIST extension name CDATA #IMPLIED>
<!--
The href attribute of an extension element specifies the
location of the extension.
-->
<!ATTLIST extension href CDATA #REQUIRED>
<!--
The ext-download element defines how parts of the extension
are downloaded.
-->
<!ELEMENT ext-download EMPTY>
<!--
The ext-part attribute of an ext-download element describes
the name of a part in the extension.
-->
<!ATTLIST ext-download ext-part CDATA #REQUIRED>
<!--
The download attribute of an ext-download element describes
if the resource may be lazily downloaded.
-->
<!ATTLIST ext-download download (lazy|eager) "eager">
<!--
The part attribute of an ext-download element describes the
name of the part it belongs to in the current JNLP file.
-->
<!ATTLIST ext-download part CDATA #IMPLIED>
<!--
The property element describes a name/value pair that is
available to the launched application as a system property.
-->
<!ELEMENT property EMPTY>
<!--
The name attribute of the property element describes the name
of a system property.
-->
<!ATTLIST property name CDATA #REQUIRED>
<!--
The value element describes the value of a system property.
-->
<!ATTLIST property value CDATA #REQUIRED>
<!--
The package element defines a relationship between a Java
package or class name and a part.
-->
<!ELEMENT package EMPTY>
<!--
The name attribute of the package element describes the name
of a package or class.
-->
<!ATTLIST package name CDATA #REQUIRED>
<!--
The part attribute of the package element describes the part
that contains the specified package or class.
-->
<!ATTLIST package part CDATA #REQUIRED>
<!--
The recursive attribute of the package element indicates if
all sub-packages of this particular package is also included.
-->
<!ATTLIST package recursive (true|false) "false">
<!--
The application-desc element describes how to launch a
Java-based application. It contains information about the
main class and arguments.
-->
<!ELEMENT application-desc (argument*)>
<!--
The main-class attribute of the application-desc element
describes the main class of an application.
-->
<!ATTLIST application-desc main-class CDATA #IMPLIED>
<!--
The argument elements describe the ordered set of arguments
to an application. These arguments will be passed into the
main method of the application's main class.
-->
<!ELEMENT argument (#PCDATA)>
<!--
The applet-desc element describes how to launch a Java
Technology-based Applet. It contains information about, e.g.,
the main class, size, and parameters.
-->
<!ELEMENT applet-desc (param*)>
<!--
The documentbase attribute of the applet-desc element
describes the documentbase for the applet as a URL.
-->
<!ATTLIST applet-desc documentbase CDATA #IMPLIED>
<!--
The main-class attribute of the applet-desc element describes
the name of the main Applet class.
-->
<!ATTLIST applet-desc main-class CDATA #REQUIRED>
<!--
The name attribute of the applet-desc element describes the
name of the Applet.
-->
<!ATTLIST applet-desc name CDATA #REQUIRED>
<!--
The width attribute of the applet-desc element describes the
width of the Applet in pixels.
-->
<!ATTLIST applet-desc width CDATA #REQUIRED>
<!--
The height attribute of the applet-desc element describes the
height of the Applet in pixels.
-->
<!ATTLIST applet-desc height CDATA #REQUIRED>
<!--
The param element describes a parameter to an Applet.
-->
<!ELEMENT param EMPTY>
<!--
The name attribute of the param element describes the name of
a parameter.
-->
<!ATTLIST param name CDATA #REQUIRED>
<!--
The value attribute of the param element describes the value
of a parameter.
-->
<!ATTLIST param value CDATA #REQUIRED>
<!--
The component-desc element specifies a component extension.
-->
<!ELEMENT component-desc EMPTY>
<!--
The installer-desc element specifies an installer extension.
-->
<!ELEMENT installer-desc EMPTY>
<!--
The main-class attribute of the installer-desc element
describes the main class for the installer/uninstaller.
-->
<!ATTLIST installer-desc main-class CDATA #IMPLIED>
<!--
The shortcut element describes an application's preferences
for desktop integration.
-->
<!ELEMENT shortcut (desktop?, menu?)>
<!--
The online attribute of the shortcut element describes an
application's preferences launching shortcuts online or
offline
-->
<!ATTLIST shortcut online (true | false) "true">
<!--
The desktop element indicates that a shortcut on the desktop
is desired.
-->
<!ELEMENT desktop EMPTY>
<!--
The menu element indicates that a shortcut in a menu is
desired.
-->
<!ELEMENT menu EMPTY>
<!--
The submenu attribute of the menu element indicates where in
the menu a shortcut is desired.
-->
<!ATTLIST menu submenu CDATA #IMPLIED>
<!--
The association element describes an application's
preferences for desktop associations.
-->
<!ELEMENT association EMPTY>
<!--
The extensions attribute of the association element indicates
a list of extensions to associate.
-->
<!ATTLIST association extensions CDATA #REQUIRED>
<!--
The mime-type attribute of the association element indicates
a mime-types to associate.
-->
<!ATTLIST association mime-type CDATA #REQUIRED>
<!--
The related-content element described additional content that
may be integrated with the application.
-->
<!ELEMENT related-content (title?, description*, icon*)>
<!--
The href attribute of the related-content element contains a
URL to a location on the web containing additional related
content for the application.
-->
<!ATTLIST related-content href CDATA #REQUIRED>

 

 

 
												

JNLP : Java Glossary相关推荐

  1. 火狐浏览器中打开java_Ubuntu下通过Firefox Opera Chromium浏览器直接执行java应用程序(打开java jnlp文件)实现在服务器远程虚拟控制台完成远程管理的方法...

    远程虚拟控制台依赖于java运行环境(jre),在通过浏览器打开链接前,系统必须安装jre环境,远程管理控制台其实就是一个java程序,打开相应的网站会下载一个jnlp(java网络加载协议)的文件, ...

  2. java打开jnlp_如何打开jnlp

    展开全部 可用java程序32313133353236313431303231363533e78988e69d8331333337613862打开,首先要确定你已经装好了jre改好了环境变量然后,开始 ...

  3. java jnlp 签名_JNLP(jar包签名)

    JNLP(Java Network Launching Protocol )是java提供的一种可以通过浏览器直接执行java应用程序的途径,它使你可以直接通过一个网页上的url连接打开一个java应 ...

  4. java jnlp 运行_java怎么运行jnlp文件 jnlp文件怎么打开

    jnlp文件怎么打开 可用java程序打开,首先要确定你已经装好了jre改好了环境变量然后,开始――运行――cmdjavaws D:\××××\××××\××××.jnlp如果你的jre装的没有问题, ...

  5. 运行java提示未签名_java – JNLP:在签名代码中加载未签名的代码

    我们在克服Java webstart的混合代码错误时遇到了困难.总之,我们有我们的主要JNLP文件,我们已经签署了它直接加载的所有代码.我们已将all-permissions选项添加到主JNLP中.它 ...

  6. java 之JNLP

    JNLP -- java 客户端开发 一JNLP介绍: 在java开发的早期,重点被放在了客户端开发.语言中对于applet和安全下载的支持对于万维网(WWW)的发布看上去是个不错的主意.但是现实是j ...

  7. Java DNS查询内部实现

    源码分析 在Java中,DNS相关的操作都是通过通过InetAddress提供的API实现的.比如查询域名对应的IP地址: String dottedQuadIpAddress = InetAddre ...

  8. Java泛型-为什么允许“扩展T”但不允许“实现T”?

    本文翻译自:Java generics - why is "extends T" allowed but not "implements T"? I wonde ...

  9. Index of Java

    JNLP(Java Network Launching Protocol) JAWS(Java Web Start) JNI(Java Native Interface) JFlex&Java ...

最新文章

  1. 【AJAX】Ajax学习总结
  2. Python-functools (reduce,偏函数partial,lru_cache)
  3. 4.Java中的关键字和标识符
  4. protobuf入门教程(五):枚举(enum)、包(package)
  5. 高端android手机,高端机型很难选择?这几款手机就很不错,你肯定有中意的
  6. 【LeetCode】拓扑排序
  7. Flume实战采集文件内容存入HDFS
  8. 马斯克一说特斯拉“全自动驾驶”,大家就想笑
  9. Twitter数据抓取的方法(三)
  10. 浅谈php的抽象类和接口类
  11. 企业到底需要何种数据分析挖掘工具?
  12. 万能平板刷机软件_平板电脑怎么刷机 平板电脑刷机方法【教程】
  13. CRM客户关系管理系统需求分析文档
  14. 基于51单片机的步进电机驱动程序
  15. 关于能力模型的思考总结
  16. IDEA社区版详细安装2022最新版(保姆式)
  17. jQuery--样式操作(addClass()、removeClass()、toggleClass()、css())详解
  18. 10-特质-Scala
  19. 入门百度地图 JavaScript API
  20. NOTIFIER诺帝菲尔消防主机电源维修及日常维护

热门文章

  1. Android - weight,patch图片,shape图形,android开发入门书籍推荐
  2. 安卓应用开发Socket通信 客户端+服务器端
  3. go-testify和robfig
  4. 渗压自动化监测设备如何选型
  5. 1.测试步骤,分类,流程,8要素
  6. jupyter notebook如何导入使用pygal模块
  7. MySQL数据表字段类型有哪些
  8. 华擎主板的instant flash功能问题
  9. 微前端:使用qiankun框架从 0-1 搭建vue构成微前端项目
  10. Manjaro + Windows 双系统安装指南