Category Archives: Java Web Start

Java Web Start Application fails: connection refused exception when trying to run a jar via Java web start

I wrote my first Java Web Start application. Here as follows,

Step 1: My simple Hello World Swing java program

package com.saravanansivaji.swing;

import java.awt.EventQueue;
import javax.swing.JFrame;

public class HelloWorldSwing extends JFrame {

public HelloWorldSwing() {

setTitle("Hello World example");
setSize(300, 200);

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {
public void run() {
HelloWorldSwing ex = new HelloWorldSwing();

Step 2: I packed this as executable JAR file, myswing.jar

Step 3: Created a web application folder “apps” under Tomcat Server web application directory “webapps”.


Step 4: Created a JNLP (Java Network Launch Protocol) file in the web folder “apps”, myswing.jnlp,

<?xml version=”1.0″ encoding=”utf-8″?>

<jnlp spec=”0.2 1.0″

<title>Welcome to Swing World</title>
<vendor>Saravanan Sivaji</vendor>
<homepage href=”index.html”/>
<description>Hello Swing World</description>
<icon href=”saravanansivaji.JPEG”/>

<j2se version=”1.5+”/>
<jar href=”myswing.jar”/>

<application-desc main-class=”com.saravanansivaji.swing.HelloWorldSwing”/>


Step 5: Create an index page that invokes JNLP file


<TITLE> New Document </TITLE>

<a href=”myswing.jnlp”>Run Swing Master</a>

So finally, my tomcat web folder “apps” contains the following files
1) a JAR file to launch
2) a JNLP file to invoke JAR
3) a index.html file to invoke JNLP file

Now running the tomcat web server and hitting the browser with URL

http://localhost:8080/apps/ Connection refused: connect
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 Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown 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)

The issue occurred, my tomcat web server was running on 8081 port. But I had hit on localhost:8080 port.

Java web start application was launched the HelloWorldSwing component successfully.

Happy ending 🙂