在某些计算机上加载小程序时出现 ClassNotFoundException

发布于 2024-12-03 17:57:17 字数 1264 浏览 0 评论 0原文

在某些机器上运行这个小程序将无法工作,但在其他机器上它却可以正常工作。在所有情况下看起来 JRE 1.6.0_26 都已安装。

<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>

这是错误:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱的那么颓废 2024-12-10 17:57:17
  1. http://kash-dev/applet/ 不是一个真正的 URL,所以我很惊讶它可以在任何计算机上运行。
  2. width:0, height:0 任何有自尊的垃圾邮件抑制软件(病毒检查程序等)都会默默地自动删除大小为 0 的 HTML 元素。给它一个 10x10 的大小并使用 CSS 隐藏它(可能使用 display 属性,但更好的方法是将其移动到“离开页面”的位置 - 例如,将其放置在相对于顶部的 -50、-50 处-页面左角)。
  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).
花期渐远 2024-12-10 17:57:17

我会仔细检查每台机器上的 Java 版本。我唯一一次看到这种错误 - ClassNotFound 在一台计算机上,但在另一台计算机上没有 - 是当 applet 或 jar 由比安装的版本更高的 Java 版本编译时,例如尝试在一台计算机上运行 Java 7 编译的 applet/jar具有 Java 6 的机器。

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.

不寐倦长更 2024-12-10 17:57:17

事实证明,Java 控制面板中的网络代理设置被设置为“用户代理服务器”,尽管其地址/端口的设置与“浏览器设置”中的设置相同 JVM 无法解析 JAR 文件网址正确。切换到“使用浏览器设置”解决了问题。谢谢所有回复的人。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文