Java applet jnlp + libraries

核能气质少年 提交于 2019-12-24 10:36:45

问题


I am trying to add libraries to applet. I am using the jnlp + deploy java javascript. Everything seems to be configured correctly, bud the classes are not found (class not found exception).

Here is my code:

JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="." href="">
    <information>
        <title>KeystoreTestApplet</title>
        <vendor>Paulie</vendor>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.6+"
              href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="KeystoreTestApplet.jar" main="true" />
        <jar href="xmlsec-1.4.5.jar" />
        <jar href="xml-apis-1.3.03.jar" />
        <jar href="xercesImpl-2.9.1.jar" />
        <jar href="xalan-2.7.1.jar" />
        <jar href="sunpkcs11.jar" />
        <jar href="serializer-2.7.1.jar" />
        <jar href="commons-logging-api-1.1.jar" />
        <jar href="commons-logging-1.1.jar" />
    </resources>
    <applet-desc 
         name="KeystoreTestApplet"
         main-class="KeystoreJApplet"
         width="600"
         height="370">
           <param name="MAYSCRIPT" value="true"/> 
     </applet-desc>
     <update check="background"/>
  <security>
    <all-permissions/>
  </security>       
</jnlp>

HTML:

<script src="deployJava.js"></script>
<script>
    var attributes = { codebase:'.', code:'KeystoreJApplet', width:600, height:370} ;
    var parameters = {jnlp_href: 'KeystoreTestApplet.jnlp', mayscript: 'true'} ;
    deployJava.runApplet(attributes, parameters, '1.6');
</script>

The applet jar, html page and the libraries jars are in the same directory.

Thanks for your help.


回答1:


<jnlp spec="1.0+" codebase="." href="">
  • If this is an embedded applet, leave the codebase out.
  • If the applet is free floating, use an explicit (not relative) URL for the codebase.

While you're at it, either specify a sensible value for the href, or remove the entire field.


It also pays to validate JNLP files when they don't work as expected. I (helped write &) recommend JaNeLA.


BTW - is mayscript supported in JNLP applets?




回答2:


I have found the actual problem on a little bit different spot.

The libraries are not included from the paths in jnlp file, but in manifest. The manifest paths had been specified by IDE as lib/{library}.jar. So java was searching for the jars in a different directory.



来源:https://stackoverflow.com/questions/6522737/java-applet-jnlp-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!