Java JNLP 扩展无法在 Internet Explorer 中打开

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

JNLP Extension does not open in Internet Explorer

javainternet-explorerjava-web-startjnlp

提问by ballBreaker

I am having an issue of opening *.jnlp extensions using Internet Explorer. The extension opens properly in Chrome and Firefox, leading me to believe it is an issue with IE and possiblythe web server/JNLP configuration. Specifically, internet explorer opens the *.jnlp file as an *.xml script instead of downloading the file or opening it with java web start.

我在使用 Internet Explorer 打开 *.jnlp 扩展时遇到问题。该扩展程序在 Chrome 和 Firefox 中正确打开,让我相信这是 IE 的问题,也可能是 Web 服务器/JNLP 配置的问题。具体来说,Internet Explorer 将 *.jnlp 文件作为 *.xml 脚本打开,而不是下载文件或使用 java web start 打开它。

Example:

例子:

<?xml version="1.0" encoding="utf-8" ?>
- <!--
 JNLP File for Downtime Registration Application
  -->
- <jnlp spec="1.7+" codebase="http://foo:8080/bar" href="bar.jnlp">
- <information>
  <title>FOO</title>
  <vendor>FOO Inc.</vendor>
  <description>FOO BAR System</description>
- <shortcut online="false">
  <desktop />
  <menu submenu="FOO" />
  </shortcut>
  </information>
- <security>
  <all-permissions />
  </security>
- <resources>
  <j2se version="1.7+" java-vm-args="-client" />

  ... 

  </resources>
  <application-desc main-class="FooBarMainApp" />
  </jnlp>

I have tried the following "Fixes"/workarounds to no avail:

我尝试了以下“修复”/解决方法无济于事:

  • Run IE as Administrator
  • Adding URL to compatibility view
  • Changing JAVA settings to "Always allow JNLP/MIME"
  • Reset internet explorer advanced settings
  • Change the MIME extension settings in the web.xml file of the web server
  • Change IE setting to always allow file downloads
  • 以管理员身份运行 IE
  • 将 URL 添加到兼容性视图
  • 将 JAVA 设置更改为“始终允许 JNLP/MIME”
  • 重置 Internet Explorer 高级设置
  • 更改 Web 服务器的 web.xml 文件中的 MIME 扩展设置
  • 更改 IE 设置以始终允许文件下载

Update:I was able to fix this issue with the workaround I posted below. However, I am looking for a more permanent fix if anyone has suggestions. Specifically, I am looking for a way to fix this on the business/server side if at all possible. It would be nice if the users didn't need to change any settings on their side (other then switching from IE to a different browser).

更新:我能够使用我在下面发布的解决方法解决此问题。但是,如果有人有建议,我正在寻找更永久的修复方法。具体来说,如果可能的话,我正在寻找一种在业务/服务器端解决此问题的方法。如果用户不需要更改他们这边的任何设置(然后从 IE 切换到不同的浏览器),那就太好了。

MIME-Mapping in web.xml:

web.xml 中的 MIME 映射:

  <mime-mapping>
    <extension>jnlp</extension>
    <mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>

采纳答案by ballBreaker

I ended up fixing this problem by changing a specific setting within Internet Explorer.

我最终通过更改 Internet Explorer 中的特定设置解决了这个问题。

Tools -> Internet Options -> Security -> Custom Level... -> Miscellaneous -> Enable MIME Sniffing- > Disable

工具 -> Internet 选项 -> 安全 -> 自定义级别... -> 其他 -> 启用 MIME 嗅探 ->禁用

It took me a while to find this fix, so I'm including it here in case anyone else has this issue as well.

我花了一段时间才找到此修复程序,因此我将其包含在此处,以防其他人也遇到此问题。

PS: This is more of a workaround then a permanent fix. Any additional insight would be helpful.

PS:这更像是一种解决方法,而不是永久性修复。任何额外的见解都会有所帮助。

Update: Ended up adding <%@ page contentType="application/x-java-jnlp-file" %>to the beginning of the JNLP file and then building the war. Essentially the JNLP would automatically launch but give a parsing error. Once this line was then taken out of the JNLP and the WAR was re-built, the JNLP would launch javawebstart and the parsing error was gone (AKA Problem Solved). Don't really know why, but this magicseemed to work.

更新:最终将<%@ page contentType="application/x-java-jnlp-file" %> 添加到 JNLP 文件的开头,然后构建战争。本质上,JNLP 会自动启动,但会出现解析错误。一旦这条线从 JNLP 中取出并重新构建 WAR,JNLP 将启动 javawebstart 并且解析错误消失(AKA Problem Solved)。不知道为什么,但这种魔法似乎奏效了。

回答by Jose Manuel Gomez Alvarez

I store my JWS application out of the EAR/WAR, along with all signed libraries.

我将我的 JWS 应用程序以及所有签名库存储在 EAR/WAR 之外。

If the JWS application is hosted in an Apache web server, in httpd.conf, you can add the type as follows:

如果 JWS 应用程序托管在 Apache Web 服务器中,则可以在 httpd.conf 中添加类型,如下所示:

AddType application/x-java-jnlp-file .jnlp

Reference here: http://httpd.apache.org/docs/current/mod/mod_mime.html

参考这里:http: //httpd.apache.org/docs/current/mod/mod_mime.html

回答by Zakaria

JNLP issue could be fixed by following the steps below:

JNLP 问题可以通过以下步骤修复:

  1. Open Mozilla Firefox and then download the JNLP extention. Mozilla Asked me how to open it, I chose Open with javaws (on C:\Program Files\Java\jre1.8.0_161\lib).
  2. Choose apply this choice from now on.
  1. 打开 Mozilla Firefox,然后下载 JNLP 扩展。Mozilla 问我怎么打开,我选择Open with javaws(上C:\Program Files\Java\jre1.8.0_161\lib)。
  2. 从现在开始选择应用此选择。

I tried to open it on Internet explorer and it worked automatically.

我尝试在 Internet Explorer 上打开它,它自动运行。

Or from Dowloaded file click right on JNLP extention file, open with javaws (on C:\Program Files\Java\jre1.8.0_161\lib). I did not try this one but i think it should work.

或者从下载的文件中右键单击 JNLP 扩展文件,使用 javaws 打开(在 上C:\Program Files\Java\jre1.8.0_161\lib)。我没有尝试过这个,但我认为它应该有效。