Where to Start with Java Web Start
Launching an Application Using Java Web Start
As discussed previously, you need a web page to launch an application with Java Web Start. As an example, take the following code snippet for a HTML file named MyApp.html, which contains a link to launch the application pointing to MyApp.jnlp:<html> <head> <title>JNLP usage demo!</title> </head> <body> <a href="MyApp.jnlp">Launch My Application</a> </body> </html>
When you invoke the file MyApp.html from a browser with a URL that points to the file (maybe something like http://localhost:8080/MyApp.html), a web page will display the link for "Launch My Application." On clicking this link (as long as the .jnlp MIME type is configured), Java Web Start launches the application MyApp with the parameters provided in the demo JNLP file.
When Java Web Start Is Not Available on User's System
During development, you usually have Java Web Start installed on most of your systems, but this may not always be the case during deployment. Many times, end-user systems will not have Java Web Start installed and hence the clients will not behave as you expect. The user will just assume that your application does not work.
<SCRIPT LANGUAGE="JavaScript"> var javawsInstalled = 0; isIE = "false"; if (navigator.mimeTypes && navigator.mimeTypes.length) { jnlpTrue = navigator.mimeTypes['application/x-java-jnlp-file']; if (jnlpTrue) { javawsInstalled = 1; } } else { isIE = "true"; } </SCRIPT>
The above JavaScript verifies whether Java is installed when the browser is Netscape. You can expand the script to cover Internet Explorer as well.
This article has given you enough information to get started with Java Web Start. When you have mastered the basics, you can accomplish much more with the technology by customizing the .jnlp file and exploring more of its concepts.
For Further Reading
About the Author
Sridhar M S is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.Page 3 of 3