4

I'd like to use the deployJava.js tool to have Java automatically detect the currently installed JRE and install an updated version if necessary. My initial impression when reading about deployJava.js was that it would do this out of the box when you simply set a version number as a function parameter for the "runApplet" function. But this has never seemed to work.

Is it even possible to do this, and if so, how?

Here is my current code for launching my applet:

<script type="text/javascript" src="https://www.java.com/js/deployJava.js"></script>
<script type="text/javascript">
    var attributes = {id:"applet", name:"TheApplet", code:"TheApplet"}; 
    var parameters = {jnlp_href: "http://localhost/TheApplet.jnlp"};
    deployJava.runApplet(attributes, parameters, "1.6.0_31");
</script>

Thanks

Pryo
  • 690
  • 1
  • 10
  • 24

2 Answers2

3

I'm sure there's some way to get deployJava.installLatestJRE() to work, but in my tests it seems to do absolutely nothing.

But as a workable solution I simply used the deployJava.versionCheck() function to check for the required version and then used JavaScript to forward the user to "http://java.com/en/download/testjava.jsp" where they can then download the latest version, if necessary.

<script type="text/javascript" src="https://www.java.com/js/deployJava.js"></script>
<script type="text/javascript">
    if (deployJava.versionCheck("1.6.0_31+") == false) {                   
        userInput = confirm(
                "You need the latest Java(TM) Runtime Environment. " +
                "Would you like to update now?");        
        if (userInput == true) {  
            window.location = "http://java.com/en/download/testjava.jsp";
        }
    }
    else
    {
        var attributes = {id:"applet", name:"TheApplet", code:"TheApplet"}; 
        var parameters = {jnlp_href: "http://localhost/TheApplet.jnlp"};
        deployJava.runApplet(attributes, parameters, "1.6.0_31");
    }
</script>
Pryo
  • 690
  • 1
  • 10
  • 24
  • This is a nice way to override the current deployJava.js behaviour when no Java is installed which refreshes the applet page once a second while taking 2-3 minutes to download and install the current JRE. – ChrisWhoCodes Jan 15 '13 at 14:38
  • How can I run a java program(but not an applet) which will launch a desktop icon after setting up the required JRE installed/updated. – NawazSE Feb 17 '15 at 07:05
0

i tested it in slightly different context (application instead of applet), this worked for me. so you might try use '' instead of "" and just pass 1.6 and see what happens

deployJava.createWebStartLaunchButton('http://localhost:8080/file.jnlp', 1.7)
Aksel Willgert
  • 11,367
  • 5
  • 53
  • 74