Java Web Start应用程序无法从快捷方式更新 [英] Java Web Start app fails to update from a shortcut

查看:117
本文介绍了Java Web Start应用程序无法从快捷方式更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Java Web Start部署了一个Java(FX)桌面应用程序。更新工作正常,但只有手动运行下载的JNLP,它们不能从安装到桌面和菜单的快捷方式工作。



这是我的JNLP:

 <?xml version =1.0encoding =utf-8?> 
< jnlp codebase =http://192.168.1.85/deploy/spec =1.0xmlns:jfx =http://javafx.comhref =Companyapp.jnlp>

< information>

< title> Companyapp< / title>
< vendor>媒体公民< / vendor>
< description> Companyapp Presentation Desktop< / description>
< homepage href =http://192.168.1.85/deploy//>

< offline-allowed />

< shortcut online =falseinstall =true>
< desktop />
< menu submenu =Companyapp/>
< / shortcut>

< icon kind =快捷方式href =http://192.168.1.85/deploy/icons/32x32.gifwidth =32height =32/>
< icon kind =快捷方式href =http://192.168.1.85/deploy/icons/64x64.gifwidth =64height =64/>
< icon kind =splashhref =http://192.168.1.85/deploy/icons/splash_screen.jpgwidth =1024height =768/>
< / information>

< update check =alwayspolicy =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.jarmain =truedownload =eager/>
< jar href =http://192.168.1.85/deploy/libs/async-http-client-1.7.8.jarsize =477791download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-codec-1.7.jarsize =259600download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-io-2.4.jarsize =185140download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-lang3-3.1.jarsize =315805download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-logging-1.1.jarsize =52915download =eager/>
< jar href =http://192.168.1.85/deploy/libs/json-simple-1.1.1.jarsize =23737download =eager/>
< jar href =http://192.168.1.85/deploy/libs/slf4j-api-1.7.2.jarsize =26083download =eager/>
< jar href =http://192.168.1.85/deploy/libs/sqlite-jdbc-3.7.15-SNAPSHOT.jarsize =3702257download =eager/>
< jar href =http://192.168.1.85/deploy/libs/ws-commons-util-1.0.2.jarsize =34407download =eager/>
< jar href =http://192.168.1.85/deploy/libs/xmlrpc-client-3.1.3.jarsize =58573download =eager/>
< jar href =http://192.168.1.85/deploy/libs/xmlrpc-common-3.1.3.jarsize =109131download =eager/>
< jar href =http://192.168.1.85/deploy/libs/zt-zip-1.5.jarsize =33059download =eager/>
< jar href =http://192.168.1.85/deploy/libs/javaws.jarsize =893738download =eager/>
< / resources>

< jfx:javafx-desc width =0height =0main-class =com.mediacitizens.companyapp.presentation.desktop.Mainname =Company App/> ;
< application-desc main-class =com.mediacitizens.companyapp.presentation.desktop.Main/>
< / jnlp>

以下是我的程序安装快捷方式的一部分:

  //安装快捷方式
尝试
{
IntegrationService is = null;
try
{
is =(IntegrationService)ServiceManager.lookup(javax.jnlp.IntegrationService);
}
catch(UnavailableServiceException use)
{
throw new ApplicationError(use.getLocalizedMessage());
}

如果(!is.hasDesktopShortcut())
{
if(!is.requestShortcut(true,true,Companyapp))
{
throw new ApplicationError(Integration failed。);
}
}
else
{
//initialController.dialog(\"短暂存在,离开!,null);
}
}
catch(ApplicationError e)
{
initialController.dialog(无法在您的计算机上集成快捷方式。\Cause:+ e。 getLocalizedMessage(),我明白,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 任何人都知道解决方法?



在错误中,它说


获取每个jnlp作为扩展名的rif。意思是混合在一起。在这种情况下,


所以我应该将JavaFX作为一个jar混合到我的JNLP中?

解决方案

我设法解决问题,而不删除< offline-allowed /> ,这里是JNLP:

 <?xml version =1.0encoding =utf-8?> 
< jnlp spec =6.0+codebase =http://192.168.1.85/deploy/href =Companyapp.jnlp>

< information>
< title> Companyapp< / title>
< vendor>媒体公民< / vendor>
< description> Companyapp Presentation Desktop< / description>
< homepage href =http://192.168.1.85/>

< shortcut online =trueinstall =true>
< desktop />
< menu submenu =Companyapp/>
< / shortcut>

< offline-allowed />

< icon kind =快捷方式href =http://192.168.1.85/deploy/icons/32x32.gifwidth =32height =32/>
< icon kind =快捷方式href =http://192.168.1.85/deploy/icons/64x64.gifwidth =64height =64/>
< icon kind =splashhref =http://192.168.1.85/deploy/icons/splash_screen.jpgwidth =1024height =768/>
< / information>

< update check =alwayspolicy =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.jarmain =true/>
< jar href =http://192.168.1.85/deploy/libs/async-http-client-1.7.8.jarsize =477791download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-codec-1.7.jarsize =259600download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-io-2.4.jarsize =185140download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-lang3-3.1.jarsize =315805download =eager/>
< jar href =http://192.168.1.85/deploy/libs/commons-logging-1.1.jarsize =52915download =eager/>
< jar href =http://192.168.1.85/deploy/libs/json-simple-1.1.1.jarsize =23737download =eager/>
< jar href =http://192.168.1.85/deploy/libs/slf4j-api-1.7.2.jarsize =26083download =eager/>
< jar href =http://192.168.1.85/deploy/libs/sqlite-jdbc-3.7.15-SNAPSHOT.jarsize =3702257download =eager/>
< jar href =http://192.168.1.85/deploy/libs/ws-commons-util-1.0.2.jarsize =34407download =eager/>
< jar href =http://192.168.1.85/deploy/libs/xmlrpc-client-3.1.3.jarsize =58573download =eager/>
< jar href =http://192.168.1.85/deploy/libs/xmlrpc-common-3.1.3.jarsize =109131download =eager/>
< jar href =http://192.168.1.85/deploy/libs/zt-zip-1.5.jarsize =33059download =eager/>
< jar href =http://192.168.1.85/deploy/libs/javaws.jarsize =893738download =eager/>
< / resources>

< application-desc main-class =com.mediacitizens.companyapp.presentation.desktop.Main/>
< / jnlp>

要确保服务器正确处理更新,请安装 mod_expires 为Apache,并将这个 .htaccess 在JNLP和JAR的文件夹中:

  DirectoryIndex index.html 

AddType应用程序/ x-java-jnlp文件.jnlp
AddType应用程序/ x-java-archive .jar
AddType application / x-java-archive-diff .jardiff

< IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault修改
< / IfModule>


I have deployed a Java(FX) desktop app using Java Web Start. The updates work fine but only if I run the downloaded JNLP by hand, they do not work from shortcuts installed to desktop and menu.

Here is my 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>

Just in case, here is the part of my program that installs the shortcuts:

// 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);
}


Update 1

I removed <offline-allowed /> and now it updates from a shortcut but I can't start the application offline. So apparently I should be able to? Its giving me this error:

To be fair, I do try to connect to a server on startup, but that is not causing this error: it has a 2 second timeout and looks like that:

try
{
    isOffline = !(InetAddress.getByName(Config.domain + "." + Config.serverDomain).isReachable(2000));
}
catch (IOException e)
{
    e.printStackTrace();
}

Irregardless, my code is not referenced in the error, so I guess if I don't have <offline-allowed /> I cannot run the app offline at all? Is this true? If yes, this is a massive problem for deployment with JWS, I'll probably just ditch it altogether...


Update 2

I think I may be hitting this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7121086 anyone knows a workaround?

In the bug it says

Get rif of every jnlp used as extension. meaning mix all in one. At this condition that works

So I should mix JavaFX as a jar into my JNLP?

解决方案

I managed to solve the problem without removing <offline-allowed />, here is the 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>

And to make sure the server handles updates correctly, install mod_expires for Apache and put this .htaccess in the folder where the JNLP and JAR are:

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 Web Start应用程序无法从快捷方式更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆