Deploying Java Clients with Java™ Web Start (JWS)
Christopher M. Judd
President/Consultant
Judd Solutions, LLC.
User Interface History
1980
1970 1990 2000
Terminal Client/Server Web (DisconnectedMobile Clients)
© 2004 Judd Solutions, LLC. All rights reserved.
Client Deployment Options • HTML
• Applets
• Third party tools • Enterprise
• Proprietary • Open Source • Java Web Start
Java Web Start (JWS)
• Reference implementation of JNLP
– JavaTM Network Launching Protocol & API (JNLP)
• Java clients (Swing, AWT, SWT)
• Single click deployment
• Cross platform
• Application Manager
• Works with any browser
• Integrated with JRE
© 2004 Judd Solutions, LLC. All rights reserved.
Java Launch Network Protocol (JNLP)
• Application launch and deployment
technology
• Secure (sandbox)
• Client based (Swing, AWT, SWT)
• JNLP API
JWS Features• Multiple JREs
• Security
– Code-signing – Sandboxing• Versioning and incremental updates
• Desktop integration
• Offline operation
© 2004 Judd Solutions, LLC. All rights reserved.
Installation
http://localhost:8080/sdc.jnlp
Users Computer Web Server
sdc.jnlp sdcClient.jar 1.0 sdcReport.jar 1.0 JavaSoft.com JDK sdc.jnlp JDK sdcClient.jar 1.0 sdcReport.jar 1.0 Launching Methods
• HTML Link
– Installation• Application Manager
• Shortcut
© 2004 Judd Solutions, LLC. All rights reserved.
Updating
Users Computer Web Server
sdc.jnlp sdcClient.jar 2.0 sdcReport.jar 1.0 sdc.jnlp JDK sdcClient.jar 1.0 sdcReport.jar 1.0 sdcClient.jar 2.0 sdcReport.jar 1.0 sdc.jnlp sdcClient.jar 1.0 sdcReport.jar 1.0 Application Manager
• Launch
Applications
• Add shortcuts
• Configuration
– Proxy – Manage JREs – Cache© 2004 Judd Solutions, LLC. All rights reserved.
*.jnlp
• Configuration file
• XML format
• application/x-java-jnlp-file
• Windows associates it with JWS
JNLP Example <?xml version="1.0" encoding="UTF-8"?> <jnlp codebase=“http://localhost:8080" href="sdc.jnlp"> <information> <title>Application Name</title> <vendor>Company Name</vendor> <icon href="images/image.gif"/> <homepage href="index.html"/> <description>Application Description</description> <offline-allowed/> </information> <resources> <j2se version="1.4+"/> <jar href="sdcClient.jar"/> <jar href="sdcReport.jar"/> </resources> <application-desc main-class="com.sdc.store.ui.MercuryClient"/> </jnlp>
© 2004 Judd Solutions, LLC. All rights reserved.
Setup
• Install Java Web Start on all clients
– Now comes with JRE and JDK
• Add jnlp mime-type to web server
– application/x-java-jnlp-file
• jar application
• Create web page with link to jnlp file
• Deploy jars, web page and jnlp file to web server
• Tip for loading resources
– ClassLoader.getResourceAsStream
Security
• Default (sandbox)
– Untrusted
– Limited access to network – Limited access to file system
• Override
– Trusted
– Digitally sign code – Users discretion
© 2004 Judd Solutions, LLC. All rights reserved.
Digitally signing code
• Generate a Key using keytool
– Included in the JDK
– http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.h tml
• Ant Task to sign
<signjar jar=“application.jar" alias="sdc"
keystore="${keystore}" storepass="${key.pass}"/>
JNLP Developer’s Pack
• Separate Download (See Resources)
• Contains
– Developer’s Guide
– JNLP Servlet and Servlet Guide – JNLP API (javax.jnlp.*)
– Jar diff tool
– JavaScript for detecting and installing JWS
© 2004 Judd Solutions, LLC. All rights reserved.
JNLP API
• javax.jnlp.*
• Sandbox
• Services
– BasicService – Access to codebase
– ClipboardService – Set and get clipboard contents
– DownloadService – Control resources and cache
– ExtensionInstallerService – Interact with JNLP Client
– PersistanceService – Store and retrieve local data JNLP Servlet <servlet> <servlet-name>JnlpDownloadServlet</servlet-name> <servlet-class>com.sun.javaws.servlet.JnlpDownloadServlet</servlet-class> </servlet> Servlet Configuration
<jnlp codebase="$$codebase" href=“$$name"> …
</jnlp>
<jnlp codebase=“http://localhost:8080" href=“sdc.jnlp"> …
</jnlp>
Without JNLP Servlet
© 2004 Judd Solutions, LLC. All rights reserved.
e-Lube
Open Source JNLP Clients
• Netx
– http://www.acm.vt.edu/~jmaxwell/netx/netxPa ge.html
• OpenJNLP
© 2004 Judd Solutions, LLC. All rights reserved.
Testing Toolkit • Apollo
– http://ajax.sourceforge.net/apollo/
Conclusion
JWS and JNLP are a simple, secure and
standards based way of distributing
client application over the network.
© 2004 Judd Solutions, LLC. All rights reserved.
Resources
• Java Web Start and JNLP
– http://java.sun.com/products/javawebstart/
• JNLP Developer’s Pack
– http://java.sun.com/products/javawebstart/developers.ht ml• JNLP API
– http://java.sun.com/j2se/1.4.2/docs/guide/jws/jnlp/index. html Contact Information•
http://www.juddsolutions.com
•
[email protected]
• Blog
– http://blogs.apress.com/authors.php?author=Christopher%20Jud d• Enterprise Java Development on a
Budget
© 2004 Judd Solutions, LLC. All rights reserved.