【问题标题】:Java applet not running when moved in directory structure在目录结构中移动时 Java 小程序不运行
【发布时间】:2012-06-06 19:20:19
【问题描述】:

我想知道是否有人可以帮助我解决这个问题,因为我一直在努力让它发挥作用。

有一个现有的 Java 小程序肯定可以工作,但我需要将它从目录层次结构顶部的当前位置移动到它的深处。

运行它的原始 HTML 代码是这样的:

<html>
<applet code=DSVisApp.class
archive="jcommon-1.0.16.jar,jfreechart-1.0.13.jar,
jung-graph-impl-2.0.1.jar, jung-visualization-2.0.1.jar,
gson-1.7.1.jar, jung-algorithms-2.0.1.jar, jung-api-2.0.1.jar,
collections-generic-4.01.jar,colt-1.2.0.jar" name=DSVis height=100%
width=100%>
</applet>
</html>

(我知道,我刚刚继承了它。我想让它从新位置开始工作,然后担心切换到&lt;object&gt;。)

结构是:

DSVisApp
 + bin
 + + DSVisApp.class
 + + and lots of other classes for this applet
 + src
 + a couple of other directories
jcommon-1.0.16.jar
and all the other jar files with support code

这可以使用上面的 HTML。

现在我想把它放几个目录级别,例如:

alpha
 + beta
 + + gamma
 + + + delta
 + + + + DSVisApp...
 + + + + jar files...

我以为我可以只输入一个 codebase="/alpha/beta/gamma/delta" 但如果我这样做了,我会得到:

basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1929190

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/jcommon-1.0.16.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/jfreechart-1.0.13.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/jung-graph-impl-2.0.1.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/jung-visualization-2.0.1.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/gson-1.7.1.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/jung-algorithms-2.0.1.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/jung-api-2.0.1.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/collections-generic-4.01.jar

basic: Plugin2ClassLoader.addURL parent called for
http://disco.local/alpha/beta/gamma/delta/colt-1.2.0.jar

network: Cache entry not found [url:
http://disco.local/alpha/beta/gamma/delta/DSVisApp.class, version:
null]
network: Connecting
http://disco.local/alpha/beta/gamma/delta/DSVisApp.class with
proxy=DIRECT
network: Connecting http://disco.local:80/ with proxy=DIRECT
network: Connecting
http://disco.local/alpha/beta/gamma/delta/DSVisApp.class with cookie
"SESS59f29a0af2165ae4a0b5f5e4a22a492a=i2ds99n4hd27qoi2nida5iah67;
has_js=1"
network: Cache entry not found [url:
http://disco.local/alpha/beta/gamma/delta/DSVisApp/class.class,
version: null]
network: Connecting
http://disco.local/alpha/beta/gamma/delta/DSVisApp/class.class with
proxy=DIRECT
network: Connecting http://disco.local:80/ with proxy=DIRECT
network: Connecting
http://disco.local/alpha/beta/gamma/delta/DSVisApp/class.class with
cookie "SESS59f29a0af2165ae4a0b5f5e4a22a492a=i2ds99n4hd27qoi2nida5iah67;
has_js=1"
basic: load: class DSVisApp.class not found.
load: class DSVisApp.class not found.
java.lang.ClassNotFoundException: DSVisApp.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: DSVisApp.class
Ignored exception: java.lang.ClassNotFoundException: DSVisApp.class
basic: Loading Java Applet Failed...

反正我的头发不多 - 撕掉它会很痛。

它可能是服务器或 Java 配置的东西吗?因为很明显原始版本不是指向实际的类——实际的类是在 DSVisApp/bin/DSVisApp.class)

【问题讨论】:

  • 1) “在目录层次结构的顶部” 这是否意味着“在站点的根目录”?如果不是,codebase 可能与前导 / 错误。 2)“然后担心切换到&lt;object&gt;到时候,切换到deployJava.js,如applet info. page中所述。 3) 请在发送之前查看您的帖子,注意&lt;object&gt; 将消失,除非代码格式化 - 它是尖括号和 HTML 注入。

标签: java html browser applet classnotfoundexception


【解决方案1】:

如果您将浏览器指向http://disco.local/alpha/beta/gamma/delta/DSVisApp.class,会发生什么?
如果您的服务器设置正确,系统会提示您保存 DSVisApp.class。
我猜你得到的是 404。
这表明存在 Web 服务器配置问题。

【讨论】:

    【解决方案2】:

    感谢您的建议。

    原来我做了一个毫无根据的假设(并非完全出乎意料,因为我只是顺便了解 Java)。我假设给我的代码是在服务器上运行的,记住我无权访问服务器。

    将提供的代码导出到 JAR 中,然后将其放入与第 3 方 JAR 相同的级别,然后将该 JAR 添加到存档参数的列表中即可立即解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多