Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Download correct JRE before launching the jnlp application

843802Mar 5 2009 — edited Mar 19 2009
Hi,

I have this requirement that before launching the jnlp application, the code should check the version of JRE installed on client's system, if it is less than 1.6 u10 then install the latest available JRE before launching the application.

I am using the Java Script in my jsp to achieve this objective and it is working fine with non-IE web browsers. The trouble starts when the client machine is using 1.6.0_6 jre, in that case IE is not able to download /redirect user to the sun's page for the download of latest JRE.

My java script code as follows:
<script language="JavaScript">
var launch = null;

// try to check the JRE version installed on client's machine.
//if its less than 1.6.10 redirect to Sun Micro systems website.
//and then after installation, launch Receptionst and Call Center application
function checkForInstalledJreVersionAndLaunch(appName)
{
	//detect browser used at client's machine
	var windowsIE = (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1);
	if (windowsIE) {
		alert(windowsIE);
    	document.write("<OBJECT codeBase=\"http://java.sun.com/update/1.6.0/jinstall-6u10-windows-i586.cab#Version=6,0,10,0\" classid=\"clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284\" height=0 width=0>");
    	document.write("<PARAM name=app VALUE=\"http://localhost:8080/"+appName+"/launch.jnlp\">");
		document.write("<PARAM NAME=back VALUE=true>");
		document.write("</OBJECT>");
 	}else{
 		if (navigator.mimeTypes && navigator.mimeTypes.length)
 		{
 			if(!checkWebStartWersion())
 			{
 				window.open("http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com","needdownload");
 			}
 			launch = setInterval('launchJNLP("http://localhost:8080/'+appName+'/launch.jnlp")',100);
 		}
 	}
}

function launchJNLP(app) {
    if (checkWebStartWersion()) {
        clearInterval(launch);
        window.location = app;
    }
}

function checkWebStartWersion()
{
	var isMajorVersion = false;
	var isMinorVersion = false;
	navigator.plugins.refresh(true);
	if(navigator.mimeTypes['application/x-java-jnlp-file'])
	{
		for(var i=0;i <navigator.mimeTypes.length; i++)
		{
			var pluginType = navigator.mimeTypes.type;
if(pluginType.indexOf("x-java-applet;jpi-version") > -1)
{
var jreVersion = pluginType.substring(pluginType.indexOf("_")+1,pluginType.length);
var jreUpdateNumber = parseInt(jreVersion);

if(jreUpdateNumber >= 10)
{
isMinorVersion = true;
}
}

if(pluginType.indexOf("x-java-applet;version") > -1)
{
var jreVersion = pluginType.substring(pluginType.indexOf(".")+1,pluginType.length);
var jreUpdateNumber = parseInt(jreVersion);

if(jreUpdateNumber >=6)
{
isMajorVersion = true;
}
}
}
}
return (isMajorVersion && isMinorVersion);
}

function launchApplication()
{
checkForInstalledJreVersionAndLaunch("appname");
}
</script>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2009
Added on Mar 5 2009
5 comments
1,307 views