WebStart HeadStart
Java’s WebStart was to solve some deployment problems, but recently I’ve had two deployment issues with it. The first issue is as follows; using Internet Explorer I would get the following error when trying to open a WebStart JNLP file:
An error occurred while launching/running the application. Category: Invalid Argument Error Could not load file/URL specified: C:\...\Content.IE5\...\webstart[1].jnlp
The Wrapped Exception states that this is basically a FileNotFoundException on the client side. What happened was that IE didn’t cache the JNLP file on the client side and WebStart can’t find the JNLP file when it tries to launch the application. I found some advice on forums after googling for ‘WebStart Content.IE5’ and other search terms. Some forums stated that I needed to clear IE’s cache. Others suggested that I had to move the IE cache to a different directory. What worked for me was that I had to explicitly tell IE to cache the JNLP file using some JSP code.
// Set IE HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control",
"post-check=900, pre-check=3600");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "cache");
The other problem with WebStart that I have had in the past is in the way you auto-detect if WebStart is installed. To auto-detect Sun’s documentation provides you with some nasty client side JavaScript and Vbscript code. It is nasty because it is doesn’t even works properly, a bug is filed for this. I have two machines, both of which have Java 1.4.2_08 installed. But for some reason only one machine can create a JavaWebStart.isInstalled.1.4.2.0 object using the Visual Basic script on IE. This must be a Java plugin problem. A way around this is to use IE object tag. The following bit of code is what Sun provides you to auto-detect if your client has WebStart installed.
<script type="text/javascript" language="javascript">
var javawsInstalled = 0;
var javaws12Installed = 0;
var javaws142Installed = 0;
isIE = "false";
if (navigator.mimeTypes && navigator.mimeTypes.length) {
x = navigator.mimeTypes['application/x-java-jnlp-file'];
if (x) {
javawsInstalled = 1;
javaws12Installed = 1;
javaws142Installed = 1;
}
}else {
isIE = "true";
}
</script>
<script LANGUAGE="VBScript">
on error resume next
set jws = "JavaWebStart.isInstalled"
set jws12 = "JavaWebStart.isInstalled.2"
set jws142 = "JavaWebStart.isInstalled.1.4.2.0"
If isIE = "true" Then
If Not(IsObject(CreateObject(jws))) Then
javawsInstalled = 0
Else
javawsInstalled = 1
End If
If Not(IsObject(CreateObject(jws12))) Then
javaws12Installed = 0
Else
javaws12Installed = 1
End If
If Not(IsObject(CreateObject(jws142))) Then
javaws142Installed = 0
Else
javaws142Installed = 1
End If
End If
</script>