如何在不双击 JNLP 的情况下使 java web start 自动启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36395890/
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-08-11 17:49:56  来源:igfitidea点击:

How to make java web start launch automatically without double click on the JNLP

javagoogle-chromejava-web-startjnlpmicrosoft-edge

提问by ManKeer

I have a java applet application which is accessed by our customers through our website. Since Microsoft edge and chrome stopped supporting java plug in, we converted the applet to be launched through JNLP and Java Web Start, Unfortunately, In both browsers the JNLP downloaded and the customer should double click the file in order to launch a Java Web Start.

我有一个 Java 小程序应用程序,我们的客户可以通过我们的网站访问它。由于 Microsoft edge 和 chrome 停止支持 java 插件,我们将小程序转换为通过 JNLP 和 Java Web Start 启动,不幸的是,在两种浏览器中都下载了 JNLP,客户应双击该文件以启动 Java Web Start。

Our customers totally disappointed from this behavior, And I'm trying to find a solution for this issue.

我们的客户对这种行为感到非常失望,我正在努力为这个问题找到解决方案。

采纳答案by SubOptimal

Possible solutions

可能的解决方案

1)Change the behavior in the browser to ask the user what to do when he click on a JNLP link. Then the user can select Open with: Java web start launcheror save file.

1)更改浏览器中的行为,询问用户单击 时要执行的操作JNLP link。然后用户可以选择Open with: Java web start launchersave file

editIt's working in Firefox but it doesn't work with Chrome: see related bug reports 10877and the open issues

编辑它在 Firefox 中工作,但不适用于 Chrome:请参阅相关错误报告10877未解决的问题

2)Provide a script to the user which executes
javaws https://example.com/your_application.jnlp

2)向用户提供执行的脚本
javaws https://example.com/your_application.jnlp

An example for demonstration (application link taken from Oracle tutorial: Running a Java Web Start Application)

演示示例(应用程序链接取自 Oracle 教程:运行 Java Web Start 应用程序

javaws https://docs.oracle.com/javase/tutorialJWS/samples/deployment/NotepadJWSProject/Notepad.jnlp

This will open a simple Java application.

这将打开一个简单的 Java 应用程序。

editFor the fearless there is a hacky solution for Chrome.

编辑对于无所畏惧的 Chrome,有一个 hacky 解决方案。

  1. close Chrome, and keep in mind to always make a copy of the files altered in the next steps ;-)
  2. find in the Chrome library chrome.[so|dll]the bytes jnlpand patch them as e.g. jnl-
  3. find in your Chrome user profile directory the file Preferencesand amend it as ...
  1. 关闭 Chrome,并记住始终复制在后续步骤中更改的文件;-)
  2. 在 Chrome 库中找到chrome.[so|dll]字节jnlp并将它们修补为例如jnl-
  3. 在您的 Chrome 用户配置文件目录中找到该文件Preferences并将其修改为...

.

.

"download": {
    ...
    "extensions_to_open": "jnlp",
    ...
},

Next time you click on a link to a JNLP file it will be opened automatically (with the application which is assigned to open this file type, normally it's javaws).

下次您单击 JNLP 文件的链接时,它将自动打开(使用指定用于打开此文件类型的应用程序,通常是javaws)。

The property was found after having a look into the source pref_names.cc. But Chrome treat the extension jnlpas dangerousthat's why we need to patch the library as well.

在查看源pref_names.cc后发现了该属性。但是 Chrome 将扩展程序jnlp视为危险的,这就是我们也需要修补库的原因。