October 21, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Deploying Java Web Start Applications on the JBoss Application Server

  • April 22, 2004
  • By Olexiy & Alexander Prokhorenko
  • Send Email »
  • More Articles »

Configuring JNLP Protocol Support on JBoss

As it was mentioned in the beginning of the article, we are using JBoss 3.2.3 with the included Apache Tomcat Web container. It's worth specifying that once we launch JBoss server in the default configuration, and the server is located in the C:\jboss-3.2.3 directory, so all deployment executes into the C:\jboss-3.2.3\server\default\deploy\ directory.

To configure, we need to describe new MIME-types in the web.xml file. As you should know, this file is going with every Java application and describes all configurations done to your application. If you want these configurations to be applied to all your applications on the JBoss server, you must do the following changes in the "global" web.xml file, located (in my case) in the C:\jboss-3.2.3\server\default\deploy\jbossweb-tomcat41.sar\ directory.

The changes are the following:

...
<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>
...

Creating Your Own WAR Application for JBoss

Now the time has come to gather up and to build our Java Web Start application. We won't create a working application because it's not the aim of this article. Our task is to get to know how to install Java Web Start applications on a JBoss server.

The directory tree of our WAR package is given below:

demo\green\client\DemoTest.java
demo\green\client\DemoTest.class
WEB-INF\lib\jardiff.jar
WEB-INF\lib\jnlp.jar
WEB-INF\lib\jnlp-servlet.jar
WEB-INF\web.xml
deploy.bat
index.html
demotest.jar
demotest.jnlp

The contents of the main files that you must create yourself are the following:

demo\green\client\DemoTest.java

package demo.green.client;

public class DemoTest {
   public static void main(String[] a) {
   }
}

The next command compiles our DemoTest.java code.

javac DemoTest.java

It doesn't do anything; it simply executes. It has the required main() method for this purpose.

index.html

<html>
<head><title>Demo Test of Java Web Start</title></head>
<body><center><a href="demotest.jnlp">Click Me!</a></center></body>

demotest.jnlp

<?xml version="1.0" encoding="ISO-8859-1"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/jwsdemo"
                  href="demotest.jnlp">
   <information>
      <title>Demo Test</title>
      <vendor>Green</vendor>
      <description>Demo client by Green</description>
   </information>
   <resources>
      <j2se version="1.3+" />
      <jar href="demotest.jar" main="true" />
   </resources>
   <application-desc main-class="demo.green.client.DemoTest" />
</jnlp>

The deploy.bat file is used to compile, assemble, and deploy everything mentioned above.

@echo off
set JBOSS_DIR=C:\jboss-3.2.3
jar cfv demotest.jar demo/
jar cfv jwsdemo.war WEB-INF/ index.html *.jar demotest.jnlp
copy jwsdemo.war %JBOSS_DIR%\server\default\deploy\

In principle, this is all that is required. After launching deploy.bat in your browser, you need to open http://localhost:8080/jwsdemo, click the Click Me! link, and your Java Web Start will be launched automatically. It will install your Java application (of course, it will download all required resources and libraries) and that's all. With the next launch, Java Web Start will offer to create a shortcut on your desktop, to access this application without a Web browser.

If everything was done correctly when launching the Java Web Start application, you see this dialog window:

If you execute Java Web Start Application Manager, you will see your Java application installed in it:

Now, you may try to create your own real Java applications and install them with the help of Java Web Start. Finally, we should like to mention about the moment of automatic updating your application. If you changed your application or simply added some libraries, you must simply deploy your WAR package on the JBoss server, and once your application is be launched on the client's PC, all the changes and updates will be downloaded and installed. It is very simple!





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel