Java Web Start (Jnlp) Tutorial

Here is a brief explanation about Java Web Start from SUN

“Java Web Start is a mechanism for program delivery through a standard Web server. Typically initiated through the browser, these programs are deployed to the client and executed outside the scope of the browser. Once deployed, the programs do not need to be downloaded again, and they can automatically download updates on startup without requiring the user to go through the whole installation process again.”

This tutorial shows you how to create a Java Web Start (Jnlp) file for user to download, when user click on the downloaded jnlp file, launch a simple AWT program. Here’s the summary steps :

  1. Create a simple AWT program and jar it as TestJnlp.jar
  2. Add keystore into TestJnlp.jar
  3. Create a Jnlp file
  4. Put all into Tomcat Folder
  5. Access TestJnlp.jar from web through http://localhost:8080/Test.Jnlp

Ok, let’s start

1. Install JDk and Tomcat

Install Java JDK/JRE version above 1.5 and Tomcat.

2. Directory Structure

Directory structure of this example.

3. AWT + Jnlp

See the content of, it’s just a simple AWT program with AWT supported.

package com.mkyong;
import java.awt.*;
import javax.swing.*;
import javax.jnlp.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class TestJnlp {
  static BasicService basicService = null;
  public static void main(String args[]) {
    JFrame frame = new JFrame("Mkyong Jnlp UnOfficial Guide");
    JLabel label = new JLabel();
    Container content = frame.getContentPane();
    content.add(label, BorderLayout.CENTER);
    String message = "Jnln Hello Word";
    try {
      basicService = (BasicService)
    } catch (UnavailableServiceException e) {
      System.err.println("Lookup failed: " + e);
    JButton button = new JButton("");
    ActionListener listener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        try {
          URL url = new URL(actionEvent.getActionCommand());
        } catch (MalformedURLException ignored) {
    content.add(button, BorderLayout.SOUTH);

P.S If “import javax.jnlp.*;” is not found, please include jnlp library which located at JRE/lib/javaws.jar.

4. Jar It

Located your Java’s classes folder and Jar it with following command in command prompt

jar -cf TestJnlp.jar *.*

This will packs all the Java’s classes into a new jar file, named “TestJnlp.jar“.

5. Create keystore

Add a new keystore named “testkeys”

keytool -genkey -keystore testKeys -alias jdc

It will ask for keystore password, first name, last name , organization’s unit…etc..just fill them all.

6. Assign keystore to Jar file

Attached newly keystore “testkeys” to your “TestJnlp.jar” file

jarsigner -keystore testKeys TestJnlp.jar jdc

It will ask password for your newly created keystore

7. Deploy JAR it

Copy your “TestJnlp.jar” to Tomcat’s default web server folder, for example, in Windows – C:\Program Files\Apache\Tomcat 6.0\webapps\ROOT.

8. Create JNLP file

Create a new Test.jnlp file like this

<?xml version="1.0" encoding="utf-8"?> 
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
		<title>Jnlp Testing</title>
		<vendor>YONG MOOK KIM</vendor>
		<homepage href="http://localhost:8080/" />
		<description>Testing Testing</description>
		<j2se version="1.6+" />
		<jar href="TestJnlp.jar" />
	<application-desc main-class="com.mkyong.TestJnlp" />

9. Deploy JNLP file

Copy Test.jnlp to your tomcat default web server folder also.

C:\Program Files\Apache\Tomcat 6.0\webapps\ROOT

10. Start Tomcat

C:\Tomcat folder\bin\tomcat6.exe

11. Test it

Access URL http://localhost:8080/Test.jnlp, it will prompt you to download the Test.jnlp file, just accept and double click on it.

If everything went fine, you should see following output

Click on the “run” button to launch the AWT program.

If jnlp has not response, puts following codes in your web.xml, which located in Tomcat conf folder.

Tags :

About the Author

Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


  • Cheng Song

    Hi, recently our company is considering using Java Web Start to provide some internal services. And I ran into some problems.

    We are using WebSphere as our servlet container, and when I deploy the war file into the server, typing url ending with .jnlp always returns DownloadFileNotFound. We use JNLPServlet to redirect all requests.

    Could you help me? I could send the war file to you.

  • http://[email protected] [email protected]

    I want to add an un-install option in my webstart-based application.

    Is it possible to delete the jnlp file from the Java Cache using JNLP API

  • Pingback: JAR error when using JNLP | BlogoSfera()

  • Amit

    Nice and helpful tutorial……..

  • Narendra

    and what if i want to run that jnlp without downloading it ??can anybody tell me that ?

  • kartik


    Is it possible to download an exe file on the client machine and launch it ? Can DownloadService be used for this ?


  • Carlos Kanak


    Where de JWS download the libs?


    • Raffy

      There is no lib in the example. It is too simple. If there’s a lib or other files/resources, it should be define in jnlp file under resources.

      Read more on java web start, jnlp or else use Netbeans IDE. In Netbeans, on building the project, it will automatically create the jnlp in the dist folder together with the jar and lib. No hassle.

      Java Webstart –
      Launching JWS –
      FAQs -

    • Raffy

      The jnlp should look like this:

      Hope it help. :)

  • Phil


    Do you have an JNPL sample with Maven ?
    My goal is to have an application that verify last version on server with JNLP and use maven ?


  • Programmer

    Hello, excuse my English. I have the following problem, my application creates a file with “jnlp” dynamically URLs containing multiple images to be downloaded later to be displayed by the application. Depending too many images to be informed, in which case the final size of the file with extension “. Jnlp” exceed 1MB. If I try to run this file with the extension “. Jnlp” java web start shows “File too large”, and cancels loading the file and terminates the execution.
    Is there a size limit for files with “. Jnlp”? I can not create and execute files with the extension “. Jnlp” that exceed 1MB?

    Thank you for your attention.

  • Garfield

    Hello, I desire to subscribe for this webpage to take most up-to-date updates, therefore where can i do it please assist.

  • http://MkYong Yogesh

    Hi MkYong,
    The Tutorial was very much helpful.But i am unable to launch my application ,it is giving exception as:

    Lookup failed: javax.jnlp.UnavailableServiceException: uninitialized
    Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException
    at TestJnlp$1.actionPerformed(
    at javax.swing.AbstractButton.fireActionPerformed(
    at javax.swing.AbstractButton$Handler.actionPerformed(
    at javax.swing.DefaultButtonModel.fireActionPerformed(
    at javax.swing.DefaultButtonModel.setPressed(
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
    at java.awt.Component.processMouseEvent(
    at javax.swing.JComponent.processMouseEvent(
    at java.awt.Component.processEvent(
    at java.awt.Container.processEvent(
    at java.awt.Component.dispatchEventImpl(
    at java.awt.Container.dispatchEventImpl(
    at java.awt.Component.dispatchEvent(
    at java.awt.LightweightDispatcher.retargetMouseEvent(
    at java.awt.LightweightDispatcher.processMouseEvent(
    at java.awt.LightweightDispatcher.dispatchEvent(
    at java.awt.Container.dispatchEventImpl(
    at java.awt.Window.dispatchEventImpl(
    at java.awt.Component.dispatchEvent(
    at java.awt.EventQueue.dispatchEvent(
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(
    at java.awt.EventDispatchThread.pumpEvents(
    at java.awt.EventDispatchThread.pumpEvents(
    Disconnected from the target VM, address: ‘′, transport: ‘socket’

    Process finished with exit code 0

    so wht should be the issue??

  • Bee

    I was suggested this web site through my
    cousin. I am not positive whether this put up is written through him as no one else recognize such targeted
    about my problem. You’re wonderful! Thanks!

  • karim

    I got this expetion i called my jar Talisman.jar Found unsigned entry in resource: http://localhost:8080/Talisman.jar
    at Source)
    at Source)
    at Source)
    at Source)
    at com.sun.javaws.Launcher.prepareResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main.access$000(Unknown Source)
    at com.sun.javaws.Main$ Source)
    at Source)

    • Sean

      jar file not properly signed.

  • Pingback: jnlp resource is not available in Apache Tomcat | Code and Programming()

  • Praveen Das

    Hi mkyong,
    I’m getting the below error, appreciate if you could guide me to the solution. http://localhost:8080/Test.jnlp
    at sun.reflect.GeneratedConstructorAccessor1.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at$ Source)
    at Method)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$ Source)
    at Source)
    Caused by: http://localhost:8080/Test.jnlp
    at Source)
    at Source)
    … 18 more

    When i run it as – http://localhost:8080/Test.jnlp
    i get status 404 , not sure if im missing something.

    I have copied the .jnlp and .jar file under –


  • krishna

    I am getting java.lang.NoClassDefFoundError : javafx/application/Application while running the applicatin on tomcat. can you please help on this.

  • rahul

    I want to run java web service using JNLP from remote computer. JNLP program is running on the other computer but when I click the swing button it is unable to invoke web service.where to put the jar file,jnlp file,web service in my machine’s web server(Apache Tomcat)…is it necessary to configure the web server? Please help as eraly as possible

  • Ajish

    I Got the Error

    “Unable to launch the application”

  • Hugo Bauer

    I have jws application which starts a exe and my questions is can I skip diaolog (Open Jnlp with Java Webstarter), automatically start?

  • Shanmugasundaram

    Mr Mkyong,

    Can you please give and example to debug the above JNLP Project in Eclipse?


  • Shyamala

    Hi Mykng, I have a jar file which writes output to an excel file. I use jnlp to make the application work. When i run the jnlp through Localhost, the application works fine but the output file is not generated. Could you please help me out ?

    Output file path : D:/TestFolder
    Apache tomcat is installed in C:/

    • karim

      please tell me how you solved this issue if you solved it

  • Kiran

    I like to install a swing application on Windows machine using JNLP. My basic need is , a installation directory should get created on local system when this application is installed. Also I want install/copy some files(reports) in the same installation directory when this software get installed. When this software will run, it is going to use these files from installation directory to show the data. This also need to read the hibernate configuration from the hibernate.cfg.xml file and connect to the database on same system. Also I want to configure some parameter values while installing the software using jnlp.

    Can you plz guide me on this?



  • Josh

    Thanks. Learning by example with web-based applications is much easier. That was very helpful.

  • Gurumurthy

    Hi mkyong ,

    I have a stand-alone java application (swing based).
    I want the pop-up to come up from the customer (where the application is running) machine, if any new updates (in terms of new jars/modified jars) to alert and ask the customer to apply the fix/patch, whatever you call.
    For this scenario, jnlp/webstart will be useful or think about any other java mechanism?


  • jorge74

    Is it possible to set the path and java_home directory in the jnlp?

    set path=\\server\webutil\client\jre6\bin;\\server\webutil;%path%
    set java_home=\\server\webutil\client\jre6


  • han2754


    I place TestJnlp in c:\LJava\src\com\mkyong\
    I place javaws.jar in the same directory

    from c:\LJava i do javac by :
    javac -d build src\com\mkyong\

    I got “package javac.jnlp does not exist

    what i have done wrong ?

    thank you

  • Yumi Tomoe

    excellent, thanks!

  • barbaros

    Thanks for the post.
    P.S If “import javax.jnlp.*;” is not found, please include jnlp library which located at JRE/lib/javaws.jar.
    solution for refrence problem: javaws.jar could not be found.

  • David

    Where it says

    P.S If “import javax.jnlp.*;” is not found, please include jnlp library which located at JRE/lib/javaws.jar.

    i get this when i goto compile your

    How do i “include” the jnlp library?


    • mkyong

      you can find the “javaws.jar” file in your “JRE_INSTALLED_FOLDER/lib/’

      • Alex Pagan-Ortiz

        How I can express that in the code like?

        import javax.jws.*;


      • karim

        do i need to sign it too?

  • pragash


    Thanks for the wonderful tutorial to know about jnlp. I did the same way for placing the jnlp file in web server(tomcat) root folder and it’s working fine in my machine. But, when i access from other machine, it’s not working. Getting the following error, Unable to load resource

    Any help would be appreciated.

    • srb

      Search the line in JNLP where “http://localhost:8080/” is written. Replace “localhost” with your machines IP address. It will run through any machine in ur Local Network. :)

  • Parvendra


    thanks for the tutorial.
    I have a requirement that using an applet , I want to download an exe on clients machine and run that exe automatically behind the scene. how is that possible?
    can your tutorial fit in my requirements OR do I need to change anything?

    Please help.

    Thanks in advance.


    • mkyong

      Applet, if your client accepted your Applet’s signed certificate, then you can do whatever you want.

      • http://google Vijay

        i need to work with dll in applet ,

        please if you have any tutorial help me.

  • Jude

    Can JNLP application install in windows so that all users will access the same deployment folder. That is if the application is updated by one user, the others will users get the same?

    I have seen this done in Linux where the installation is in the root folder.
    Hope to hear back on this.

    • mkyong

      Not much inputs on this, hope get some feedback from others :)

  • Pingback: Tutorial to create Java Web Start (Jnlp) file « Crazy Ideas()

  • yunta_gohan

    (Sory for my english)
    Hi I took your example as base for my small application the main problem is that works when called from command line(javaws) but no when launched from browser(firefox).I use jni to load an small library and all this is done in Fedora 13.Any ideas, thoughts ? Thanks in advance.

    • mkyong

      Mind to zip and send me your jnlp file for review?

      • yunta_gohan

        Sorry, maybe it’s a bit dumb but How do I send you an e-mail?

  • infinityxxi

    thnx for the great example!

  • Nitesh

    Is it possible to call .jnlp file from a standalone java application. I dont want to use browser. If it is possible, can you please let me know how.The whole idea is that i want to check if the client jars are different version then the server jar and if they are different, i want to download the updated jar files from the server.


  • Gnana

    It is really simple and super ……

  • Jim

    Hi! Simple (maybe dumb) question – what is the advantage of running the executable locally (by double-clicking on the Test.jnlp file) versus just going to the website again (http://myserver:8080/Test.jnlp)? Assuming that my jnlp file require connectivity to ‘myserver’. Is there any harm with just going to http://myserver:8080/Test.jnlp over and over again?

    Thx in advance!

    • mkyong

      there are no dumb question, it’s just from different perspectives. Both ways are doing the same thing, there’s no different between each other.

      One of the advantage of running through website “http://myserver:8080/Test.jnlp” is you will always get the latest jlnp version.

      • Shyam

        I am getting ClassNotFoundException is there anyone to help me out

        • mkyong

          Which class is not found?

        • ppp

          User Runnable jar instead of simple jar

  • Vikas

    When i run the app at last step its gets downloaded but its not getting launched…

    Is this bcoz of my apache mime? i use fedora 12. and apache installed.

    • mkyong

      Received your files in my email, please send me your jnlp file as well.

  • sucotronic

    Thank you so much for this simple and functional example.

  • sebastian

    yong mook kim,

    very nice blog. helps very much to get a general idea of things. good starting point for beginners and to have a quick view. good ratio between depth and lack of too many words. :-)


  • mkyong

    the root cause is your package and folder structure. Please jar your classes in a correct folder structure according to your package declaration.

  • dilip

    Without setting in Manifest File, It didn’t work.

    What can i do ?

    What are the settings to do in manifest file in a real time large application ?

  • dilip


    In the Manifest FIle, I have specified

    Manifest-Version: 1.0
    Class-Path: /lib/javaws.jar

    Then it worked as desired.

    Thanks a lot.

    • mkyong

      Nice hack ~ but when you develop a real application which included a lot of java classes, then it’s may not a good choice :)

  • Dilip

    I have uploaded the files in zip folder @
    When i run the http://localhost:8080/Test2.jnlp in browser, I am getting the below Exception

    • mkyong

      Your TestJnlp2.class is not found in TestJnlp2.jar.

      1) is package in, but the class is located at root folder. Please include the folder (com\ibm) in TestJnlp2.jar as correct structure below

      Current structure


      Correct structure


      2) Test2.jnlp contains one minor bug also, it’s point to Test.jnlp, change it to Test2.jnlp.

      Hope help :)

  • Dilip


    In the zip file i have sent, I have wrongly mentioned TestJnlp instead of TestJnlp2. When i tested, i correctly mentioned in JNLP as

    Still I am getting java.lang.ClassNotFoundException:


  • Dilip


    I have uploaded the files in zip folder @

    When i run the http://localhost:8080/Test2.jnlp in browser, I am getting the below Exception

    at$ Source)
    at Method)
    at Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
    at Source)
    at Source)

  • Dilip


    I am getting “java.lang.NoClassDefFoundError: TestJnlp” Error while i run in tomcat.

    do u know the reason ?


    • mkyong

      can you zip and send me a copy of your file, i try deploy and test it

  • Nilesh

    Thanks .. Its So helpful for Beginers…

  • bhim

    Nice how-to, thanks!
    I think by keystroke you meant keystore:)

    • mkyong

      sorry for typo, thanks, it’s fixed now :)

      • Swap


        i have written a HTML file …. which would download JNLP, however instead of downloading it displays the contents on JNLP file …. i tried to update the Glassfish via netbean but thee glassfish-web.xml is not present and also “dist” directory is not present in my Client application project ….