December 21, 2024

I’ve been playing around with Java Web Start and ran into one snag. I kept getting the following error when I tried to start an app:

JNLPException[category: Download Error : Exception: java.net.SocketException: Unexpected end of file from server : LaunchDesc: null ]

I tried testing the jar file by itself. To do this, the jar manifest file needed to include the main class. My manifest file (with an extra blank line at the end):

Manifest-Version: 1.0
Created-By: 1.3.1_03 (Sun Microsystems Inc.)
Main-Class: demo.Demo1

Then I created the jar file and ran it:

jar cmf myManifestFile test.jar demo/*.class images/*
java -jar test.jar

That worked fine. So I then verified that the MIME types on the server were set to:

application/x-java-archive .jar
application/x-java-jnlp-file .jnlp

I also analyzed the http headers with this nice little java program.

Eventually, I tried using Apache as the server and it worked! But I still couldn’t get it to work with MS IIS. Oh well.

A debugging tip, if you specifiy the codebase of the jnlp file to point to the local file, it won’t do a http request for the jar file.

<?xml version=”1.0″ encoding=”UTF-8″?>
<jnlp codebase =”file:///d:/dev/swing/demo/classes”
href=”demo1.jnlp”>
<information>
<title>Demo</title>
<vendor>XXX</vendor>
<icon href=”jws.jpg”/>
</information>
<resources>
<j2se version=”1.2+”/>
<jar href=”demo1.jar”/>
</resources>
<application-desc main-class=”demo.Demo1″/>
</jnlp>

Links:
Java Web Start Developer’s Guide
JWS FAQ