ClassNotFoundException when loading applet on some computers

主宰稳场 提交于 2019-12-11 03:15:17

问题


running this applet on some machines wont work but then on some other's it works just fine. in all cases looks like JRE 1.6.0_26 has been installed.

<script type="text/javascript" src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {codebase:'http://kash-dev/applet/',
        code:'Auth.class',
    archive:'Auth.jar',
    id: 'auth',
    width:0, height:0} ;
    var version = '1.6' ;
deployJava.runApplet(attributes, null, version);
</script>

Here's the error:

load: class Auth.class not found.
java.lang.ClassNotFoundException: Auth.class
        at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
        at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
        at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
        at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.plugin2.applet.Plugin2ClassLoader.loadCode(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)
Exception: java.lang.ClassNotFoundException: Auth.class

回答1:


  1. http://kash-dev/applet/ is not a real URL, so I'm surprised it works on any computer.
  2. width:0, height:0 Any self-respecting spam suppression software (virus checker etc.) will silently and automatically remove HTML elements with 0 size. Give it a size of 10x10 and use CSS to hide it (possibly using the display attribute, but even better by moving it to a position that is 'off the page' - e.g. by putting it at -50,-50 relative to the top-left corner of the page).



回答2:


I would double check what version of Java is on each machine. The only time I have seen this kind of error - ClassNotFound on one computer but not another - is when the applet or jar is compiled by a later version of Java than the one installed e.g. trying to run a Java 7 compiled applet/jar on a machine with Java 6.




回答3:


It turns out that the network proxy setting in Java control panel was set to "user proxy server" even-though the settings for it's address/port was identical to that set in the "browser settings" JVM was not able to resolve the JAR file URL correctly. Switching to "use browser setting" resolved the problem. Thank you all who responded.



来源:https://stackoverflow.com/questions/7368735/classnotfoundexception-when-loading-applet-on-some-computers

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