java 使用 deployJava.js 检查/自动安装最新的 Web 小程序 JRE 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10146836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 23:47:44  来源:igfitidea点击:

Use deployJava.js to check for/automatically install latest JRE version for web applet

javaappletversionauto-updatedeployjava

提问by Pryo

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.

我想使用 deployJava.js 工具让 Java 自动检测当前安装的 JRE 并在必要时安装更新版本。在阅读 deployJava.js 时,我的最初印象是,当您简单地将版本号设置为“runApplet”函数的函数参数时,它会开箱即用。但这似乎从未奏效。

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

谢谢

采纳答案by Pryo

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

我确信有一些方法可以让 deployJava.installLatestJRE() 工作,但在我的测试中它似乎什么也没做。

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.

但作为一个可行的解决方案,我只是使用 deployJava.versionCheck() 函数来检查所需的版本,然后使用 JavaScript 将用户转发到“http://java.com/en/download/testjava.jsp”,他们可以在那里如有必要,然后下载最新版本。

<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>

回答by Aksel Willgert

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

我在稍微不同的上下文(应用程序而不是小程序)中对其进行了测试,这对我有用。所以你可以尝试使用 '' 而不是 "" 并通过 1.6 看看会发生什么

deployJava.createWebStartLaunchButton('http://localhost:8080/file.jnlp', 1.7)