我可以使用java web start启动一个jar

时间:2011-11-25 12:15:48

标签: java jar jnlp executable-jar java-web-start

我正在尝试使用网络启动午餐,我收到错误 -

Java.lang.reflect.InvocationTargetException
    at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.simontuffs.onejar.Boot cannot be cast to java.applet.Applet
    at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Exception: java.lang.reflect.InvocationTargetException

JNLP包含 -

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
    <information>
        <title>Applet Takes Params</title>
        <vendor>Protype example</vendor>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.5+"
              href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="Application.jar" main="true" />
    </resources>
    <applet-desc 
         name="Application"
         main-class="com.simontuffs.onejar.Boot"
         width="800"
         height="50">
             <param name="userName" value="Ashish"/>
     </applet-desc>
     <update check="background"/>
</jnlp>

我正在尝试直接启动 Application.jar com.simontuffs.onejar.Boot 是为JAR指定的主类。

1 个答案:

答案 0 :(得分:3)

由于您使用的是applet-desc标记,因此您的Boot类必须扩展Applet(或JApplet)。基于堆栈跟踪,看起来该类不会扩展其中任何一个。

如果它不是小程序,请使用application-desc代替applet-desc