Hey Guys, I am working on the research and development on
whether we can use Java Web Start in our project or not. So here are my
findings till now with practical as I have already posted demo as well.
Java Web Start is a platform designed by the Sun for running
java applications from the browsers.
The requirement on which I am working is whether we can
handle automatic update or also only the one jar update out of multiple jars
which really has code change or any other update. Version management and few
others.
JWS (Java Web Start) can run on any platform, so it’s a cross
platform.
We can handle memory, heap and other parameters through JWS.We
can bundle multiple jars of a project and execute JNLP file (will explain) to
download all those jars on local system to speed up the frequent application
access. If there is any change in the project or in any jar or configuration
file, we can handle it and can download only changed jar or file from the
server by changing our JNLP file.
JNLP is Java Network Launching protocol and can be used for
web start. It’s an XML file with configuration settings for our java application.
It has XML schema which specify that how we can execute or launch our java
application.
For our browser or the server on which we are running JNLP,
to recognize this file we need to set MIME type application/x-java-jnlp-file. For example to make it recognized by
the Web Sphere server we need to add MIME type as mentioned below.
and then add jnlp extension
JNLP features:
1.
Includes .jar file path and main class name
2.
The way server is configured, we can also
configure if browser is not configured and execute jnlp which will download
applicaition. We need to configure server or browser because it will pass jnlp
to JRE.
3.
We can create a jnlp which will check JRE or its
version to run application or even prompt user to install appropriate jre.
4.
After execution, user don not neet to be get
connected to internet.
5.
Updates automatically gets downloaded when user will
get connected to interbet and version handling will be handled automatically if
JNLP is properly configured.
JNLP file: (jar versioning and argument
passing to main method)
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE jnlp
PUBLIC "-//Sun
Microsystems, Inc.//DTD JNLP 1.5//EN" "http://www.netbeans.org/jnlp/DTD/jnlp.dtd">
<jnlp codebase="http://localhost:8080/examples/"
href="Test.jnlp">
<information>
<title>test</title>
<vendor>test.com</vendor>
<description>Test</description>
<offline-allowed/>
<!--
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="AAA"/>
</shortcut>
</information>
<resources>
<j2se version="1.7+" />
<jar href="Test.jar"
main="true" version="1.0"/>
<jar href="SwingDemo.jar"
version="1.0"/>
<jar href="Hello.jar"
version="1.3"/>
<jar href="World.jar"
version="1.0"/>
<property name="java.home"
value="C:\Program Files\Java\jdk1.8.0_101\"/>
<property name="jnlp.versionEnabled"
value="true"/>
</resources>
<application-desc main-class="com.sks.test.Test">
<argument>John</argument>
<argument>http://localhost:8080/examples/test.cfg</argument>
</application- desc>
</jnlp>
JNLP file (jar version and configuration version)
<?xml version="1.0"
encoding="utf-8"?> <!-- JNLP File for
Web Start Demo -->
<jnlp codebase="http://170.197.229.152:8080/deployment
" href="">
<security>
<all-permissions />
</security>
<information>
<title>Swing Application -
Test</title>
<vendor>Sharma</vendor>
<description>Swing Application -
Test</description>
<description kind="short">Swing Application -
Test</description>
<offline-allowed />
</information>
<resources>
<j2se version="1.7+"
/>
<jar href="http://<IP>:8080/examples/Test.jar"
main="true"
version="9" />
<jar href="http://<IP>:8080/examples/conf.jar"
version="1.1" />
<property name="jnlp.versionEnabled"
value="true" />
</resources>
<application-desc main-class="com.sks.test.Test">
<argument>test</argument>
</application-desc>
</jnlp>
1.
Below screen showing Java Swing application or you can create any Java application.
2.
Configured JNLP file to download multiple jars
through link mentioned in green circle:
4.
Providing main entry class while generating jar
file
Store jar file to D:\apache-tomcat-7.0.72\webapps\examples location on web server.
5. Sign this jar as per jar signing process mentioned above in the document.
6. Rename it for versioning eg. Test__V1.0.jar and SwingFileDownloadHTTP__V1.0.jar
7. Update JNLP file with below line,
8. Creating web link to run this file.
9 9. JSP file to run JNLP file