Tuesday, July 18, 2017

JAVA Web Start (JWS) JNLP Example

JWS is introduced to use client side application processing through web. Clients are downloading JNLP application and execute the application to process data.


  1. Create JAR file that you want to execute it in client side (TestJNLP.jar)
  2. Sign the file using your certificate
    1. keytool -genkey -keystore testKeys -alias test
    2. jarsigner -keystore testKeys TestJnlp.jar test
  3. Create JNLP file (Test.jnlp)
  4. Deploy JNLP file and signed JAR file in web server
  5. Download JNLP file and execute application (http://localhost:8080/Test.jnlp)

Sample JNLP file

<?xml version="1.0" encoding="utf-8"?><jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
<information>
<title>Jnlp Testing</title>
<vendor>Testing</vendor>
<homepage href="http://localhost:8080/" />
<description>Testing Testing</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" />
<jar href="TestJnlp.jar" />
</resources>
<application-desc main-class="com.test.TestJnlp" />
</jnlp>

For Windows OS, change OS type in resource XML tag as follows.

<resources os="Windows">

For native library access, you have to create DLL into JAR file and then signed the JAR file using certificate and deploy into web server. Then, you have to change JNLP file as follows.

<resources  os="Windows">       
          <j2se  version="1.6+" />    
          <jar  href="TestJnlp.jar" />
           <nativelib  href="DLLtoJAR.jar" />
  </resources>   

Create DLL into a JAR file using single command

jar cvf DLLtoJAR.jar testDLL.dll

Resource
https://dzone.com/articles/java-web-start-jnlp-hello

No comments:

Post a Comment