日期:2014-05-20  浏览次数:21051 次

java web start问题,求高手帮助!!!
异常:MissingFieldException[ 启动文件中缺少下列必需字段:<jnlp>(<application-desc>|<applet-desc>|<installer-desc>|<component-desc>)]
启动文件
Java code

<?xml version="1.0" encoding="UTF-8"?> 
<!-- file Hello.jnlp --> 
<jnlp codebase="http://127.0.0.1:8081/test" href="test.jnlp"> 
<information> 
<title>Hello jackey</title> 
<vendor>jackey jiao Sample May 2004</vendor> 
<icon href="test.gif"/> 
<offline-allowed/>
</information> 
<resources> 
<j2se version="1.6"/> 
<jar href="test.jar"/> 
</resources>
 <security>
     <all-permissions>
</security>
<component-desc/>
<applet-desc/>
<installer-desc/>
<application-desc main-class="test"/> 
</jnlp> 



------解决方案--------------------
对比了一个官方样例:
http://docs.oracle.com/javase/tutorial/deployment/webstart/examplesIndex.html#DynamicTreeDemo

XML code

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://docs.oracle.com/javase/tutorialJWS/deployment/webstart/ex6/webstart_ComponentArch_DynamicTreeDemo"
        href="dynamictree-webstart.jnlp">
    <information>
        <title>Dynamic Tree Demo</title>
        <vendor>Dynamic Team</vendor>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.6+"
              href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="DynamicTreeDemo.jar" main="true" />

    </resources>
    <application-desc
         name="Dynamic Tree Demo Application"
         main-class="webstartComponentArch.DynamicTreeApplication">
     </application-desc>
     <update check="background"/>
</jnlp>

------解决方案--------------------
语法和样例:
http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/syntax.html
------解决方案--------------------
在stackoverflow上,有人表示不同版本存在顺序问题:
http://stackoverflow.com/questions/8849535/creating-a-java-applet-exception-missing-jnlp-field

另外,建议用jnlp检查工具来进行详细检查:
http://pscode.org/janela/
------解决方案--------------------
你本地命令行用:
javaws -wait xxx.jnlp
能正常启动么?

我修改了你的jnlp文件后,本机测试解析是正常的,但因为没部署所以找不到应用而已:
XML code

<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://127.0.0.1:8081/test" href="test.jnlp">
    <information>
        <title>Hello jackey</title>
        <vendor>jackey jiao Sample May 2004</vendor>
        <icon href="test.gif"/>
        <offline-allowed/>
    </information>
    <resources>
        <j2se version="1.6"/>
        <jar href="test.jar"/>
    </resources>
    <security>
        <all-permissions/>
    </security>
    <component-desc/>
    <applet-desc/>
    <installer-desc/>
    <application-desc main-class="test"/>
</jnlp>

------解决方案--------------------
我也是瞎子蒙象了。。。