gpt4 book ai didi

java - 在浏览器中打开 JNLP

转载 作者:行者123 更新时间:2023-12-02 03:00:56 29 4
gpt4 key购买 nike

我需要在浏览器中启动 JNLP 应用程序,而不是在提供 url 并打开它时单独下载。下面是我的 jnlp 文件:

<jnlp spec="1.0+" codebase="http://localhost:7077/ChqPrint/files/" href="JNLP_print.jnlp">
<information>
<title>Jnlp Testing</title>
<vendor>xxx</vendor>
<homepage href="http://localhost:7077/ChqPrint/files/" />
<description>Testing </description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+" />
<jar href="resources/xxx.jar" main="true" />
</resources>
<application-desc main-class="com.scb.app.LaunchApplication" />
<update check="background"/>
</jnlp>

我也有我的 jar 文件 xxx.jar。下面是我的jsp文件。我的 jnlp 文件嵌入在 jsp 中,如下所示。

<!DOCTYPE html>
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:7077/ChqPrint/files/" href="cheque_print.jsp">
<information>
<title>Jnlp Testing</title>
<vendor>xxx</vendor>
<homepage href="http://localhost:7077/ChqPrint/files/" />
<description>Testing </description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="resources/xxx.jar" main="true" />
<!-- <jar href="resources/lib/jfxrt.jar" /> -->
</resources>
<application-desc main-class="com.scb.app.LaunchApplication">
<argument><%=session.getId()%></argument>
<argument><%=request.getServerName()%></argument>
</application-desc>
</jnlp>

我通常使用 URL http://localhost:7077/ChqPrint/files/cheque_print.jsp 启动我的应用程序它将下载我的 jnlp 文件作为独立应用程序。

现在的要求是在浏览器中打开 jnlp 并且他们不希望它单独打开。关于如何实现它有什么想法吗?

最佳答案

具体请查看 5.9.2 Embed the Deployment Descriptor into the Web Page 部分,它将 JNLP 数据嵌入到网页中。这将生成some JavaScript in the page调用 Oracle Java 浏览器插件,该插件将直接在浏览器中启动应用程序(如果您的部署环境支持 Oracle Java 浏览器插件)。

正如詹姆斯在评论中提到的,Oracle Java plugin is soon to be deprecated (目前在许多浏览器中默认不支持或禁用)。因此,不建议使用假定应用程序用户可以使用工作的 Oracle Java 插件的部署模式(Java Applet 或 JavaFX 应用程序嵌入并呈现在 HTML 网页中)。

如果您想要一个在浏览器中运行的应用程序,请使用基于浏览器的技术,例如 HTML5Angular或其他一些当今流行的基于 JavaScript 的库的组合(只是我的意见)。

关于java - 在浏览器中打开 JNLP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42370766/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com