How to deploy Java Web Start Applications on JBoss

INFO: Java Web Start (JWS) was deprecated in Java 9, and starting with Java 11, Oracle removed JWS from their JDK distributions. This means that clients that have the latest version of Java installed can no longer use JWS-based applications. And since public support of Java 8 has ended in Q2/2019, companies no longer get any updates and security fixes for Java Web Start.

If you are still using Java Web Start you can take a look at OpenWebStart, which is an open source reimplementation of the Java Web Start technology. This provides the most commonly used features of Java Web Start and the JNLP standard, so that your customers can continue using applications based on Java Web Start and JNLP without any change.


Java Web Start is a technology for deploying and updating desktop Java applications easily from a web server. In this tutorial we will show the necessary steps to install a Java Web Start application on JBoss AS
We will not discuss about the basics about Java Web Start here, just how to set up a Java Web Start application on JBoss AS. A complete guide about Java Web Start can be found at this location:
http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/contents.html

 

Step1: Create an empty Web Project

JWS applications need to be deployed as web applications. Create an empty application named “sampleWS”.

Step2: Create a a JNLP file which describes the Java Web Start application:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+"
      codebase="http://localhost:8080/sampleWS/" 
      href="sample.jnlp">
   <information>
      <title>Sample JWS application</title>
      <vendor>JBoss tutorials</vendor>
      <description>JWS on JBoss Demo</description>
      <homepage href="http://java.sun.com/docs/books/tutorial/deployment/webstart/running.html"/>
      <description kind="short">Example JWS application</description>
      <offline-allowed/>
   </information>
   <resources>     
       <jar href="myclasses.jar"/>   
    <j2se version="1.3+"
          href="http://java.sun.com/products/autodl/j2se"/>
   </resources>
   <application-desc main-class="com.sample.MainClass"/>
</jnlp>
In this sample, we are referencing the JWS codebase as http://localhost:8080/sampleWS.
Then we are declaring that our classes are packed into the archive “myclasses.jar”.
The main class of the application is “com.sample.MainClass”.

 

Step 3: Copy the application classes into the root of the Web application

As stated in the configuration file, the application classes will be searched in the root of the web application. So pack the application classes in a jar and place it on the root of the Web app

Step 4: Copy Java Web Start libraries in the “lib” folder of the Web application

Java Web Start needs some utility libraries which are part of the J2SE. (You can find them in the folder JAVA_HOME\sample\jnlp\servlet). They are namely three files which must be placed in the “lib” folder of your web application:

  • jardiff.jar
  • jnlp-servlet.jar 
  • jnlp.jar
Step 5: Add a web.xml file to your Web Application

You need a valid web.xml in your application which contains the mime-mappings required by Java Web Start application. The file needs to be placed in the WEB-INF folder of your web application.
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
  
<web-app>
<mime-mapping>
    <extension>jnlp</extension>
    <mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>jar</extension>
    <mime-type>application/x-java-archive</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>jardiff</extension>
    <mime-type>application/x-java-archive-diff</mime-type>
</mime-mapping>

</web-app>
Step 6: Add an index.html file

This file will be in charge to launch the Java Web Start application, by using the mime mappings configured:

<?xml version="1.0" encoding="ISO-8859-1"?>
<html>
<head><title>Demo Test of Java Web Start</title></head>
<body>
<center><a href="sample.jnlp">Launch JWS</a></center>
</body>
That’s all. The following tree resumes the structure of the Web application:
sampleWS.war
¦   index.html
¦   myclasses.jar
¦   sample.jnlp
¦
+—WEB-INF
¦   web.xml
¦
+—lib
jardiff.jar
jnlp-servlet.jar
jnlp.jar
Found the article helpful? if so please follow us on Socials