Java Web Start应用程序无法从快捷方式更新
作者:互联网
我使用Java Web Start部署了一个Java(FX)桌面应用程序.更新工作正常,但只有当我手动运行下载的JNLP时,它们才能从安装到桌面和菜单的快捷方式起作用.
这是我的JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="http://192.168.1.85/deploy/" spec="1.0" xmlns:jfx="http://javafx.com" href="Companyapp.jnlp">
<information>
<title>Companyapp</title>
<vendor>Media Citizens</vendor>
<description>Companyapp Presentation Desktop</description>
<homepage href="http://192.168.1.85/deploy/"/>
<offline-allowed/>
<shortcut online="false" install="true">
<desktop />
<menu submenu="Companyapp"/>
</shortcut>
<icon kind="shortcut" href="http://192.168.1.85/deploy/icons/32x32.gif" width="32" height="32" />
<icon kind="shortcut" href="http://192.168.1.85/deploy/icons/64x64.gif" width="64" height="64" />
<icon kind="splash" href="http://192.168.1.85/deploy/icons/splash_screen.jpg" width="1024" height="768" />
</information>
<update check="always" policy="always" />
<security>
<all-permissions/>
</security>
<resources>
<jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
</resources>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="http://192.168.1.85/deploy/Companyapp.jar" main="true" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/async-http-client-1.7.8.jar" size="477791" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-codec-1.7.jar" size="259600" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-io-2.4.jar" size="185140" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-lang3-3.1.jar" size="315805" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-logging-1.1.jar" size="52915" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/json-simple-1.1.1.jar" size="23737" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/slf4j-api-1.7.2.jar" size="26083" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/sqlite-jdbc-3.7.15-SNAPSHOT.jar" size="3702257" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/ws-commons-util-1.0.2.jar" size="34407" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/xmlrpc-client-3.1.3.jar" size="58573" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/xmlrpc-common-3.1.3.jar" size="109131" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/zt-zip-1.5.jar" size="33059" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/javaws.jar" size="893738" download="eager" />
</resources>
<jfx:javafx-desc width="0" height="0" main-class="com.mediacitizens.companyapp.presentation.desktop.Main" name="Company App" />
<application-desc main-class="com.mediacitizens.companyapp.presentation.desktop.Main" />
</jnlp>
以防万一,这是我的程序中安装快捷方式的部分:
// install shortcuts
try
{
IntegrationService is = null;
try
{
is = (IntegrationService) ServiceManager.lookup("javax.jnlp.IntegrationService");
}
catch (UnavailableServiceException use)
{
throw new ApplicationError(use.getLocalizedMessage());
}
if (!is.hasDesktopShortcut())
{
if (!is.requestShortcut(true, true, "Companyapp"))
{
throw new ApplicationError("Integration failed.");
}
}
else
{
//initialController.dialog("Shortcuts exist", "Go away!", null);
}
}
catch (ApplicationError e)
{
initialController.dialog("Failed to integrate a shortcut on your computer.\nCause: " + e.getLocalizedMessage(), "I understand", null);
}
更新1
我删除了< offline-allowed />现在它从快捷方式更新但我无法离线启动应用程序.显然我应该能够?它给了我这个错误:
公平地说,我确实尝试在启动时连接到服务器,但这不会导致此错误:它有2秒超时,看起来像这样:
try
{
isOffline = !(InetAddress.getByName(Config.domain + "." + Config.serverDomain).isReachable(2000));
}
catch (IOException e)
{
e.printStackTrace();
}
无论如何,错误中没有引用我的代码,所以我想如果我没有< offline-allowed />我根本无法离线运行应用程序?这是真的?如果是的话,这对于使用JWS进行部署来说是一个巨大的问题,我可能只是完全放弃了……
更新2
我想我可能会这样:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7121086有谁知道一个解决方法?
在它说的错误
Get rif of every jnlp used as extension. meaning mix all in one. At this condition that works
所以我应该将JavaFX作为jar混合到我的JNLP中?
解决方法:
我设法在不删除< offline-allowed />的情况下解决了问题,这里是JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" codebase="http://192.168.1.85/deploy/" href="Companyapp.jnlp">
<information>
<title>Companyapp</title>
<vendor>Media Citizens</vendor>
<description>Companyapp Presentation Desktop</description>
<homepage href="http://192.168.1.85" />
<shortcut online="true" install="true">
<desktop />
<menu submenu="Companyapp" />
</shortcut>
<offline-allowed />
<icon kind="shortcut" href="http://192.168.1.85/deploy/icons/32x32.gif" width="32" height="32" />
<icon kind="shortcut" href="http://192.168.1.85/deploy/icons/64x64.gif" width="64" height="64" />
<icon kind="splash" href="http://192.168.1.85/deploy/icons/splash_screen.jpg" width="1024" height="768" />
</information>
<update check="always" policy="prompt-update" />
<security>
<all-permissions />
</security>
<resources>
<jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp" />
</resources>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" />
<jar href="http://192.168.1.85/deploy/Companyapp.jar" main="true" />
<jar href="http://192.168.1.85/deploy/libs/async-http-client-1.7.8.jar" size="477791" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-codec-1.7.jar" size="259600" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-io-2.4.jar" size="185140" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-lang3-3.1.jar" size="315805" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/commons-logging-1.1.jar" size="52915" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/json-simple-1.1.1.jar" size="23737" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/slf4j-api-1.7.2.jar" size="26083" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/sqlite-jdbc-3.7.15-SNAPSHOT.jar" size="3702257" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/ws-commons-util-1.0.2.jar" size="34407" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/xmlrpc-client-3.1.3.jar" size="58573" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/xmlrpc-common-3.1.3.jar" size="109131" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/zt-zip-1.5.jar" size="33059" download="eager" />
<jar href="http://192.168.1.85/deploy/libs/javaws.jar" size="893738" download="eager" />
</resources>
<application-desc main-class="com.mediacitizens.companyapp.presentation.desktop.Main" />
</jnlp>
为了确保服务器正确处理更新,请为Apache安装mod_expires并将此.htaccess放在JNLP和JAR所在的文件夹中:
DirectoryIndex index.html
AddType application/x-java-jnlp-file .jnlp
AddType application/x-java-archive .jar
AddType application/x-java-archive-diff .jardiff
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "modification"
</IfModule>
标签:java,javafx,deployment,updates,java-web-start 来源: https://codeday.me/bug/20190901/1781746.html