开发者

I'm getting a "class not found" error when trying to view applet on a webpage

I have a number of classes archived in a jar file. The only thing I have loaded onto the server is the .jar file. There are a number of .class files, but the one with the init() method is called "Poker.class" My html is as follows:

<applet code=Poker
    archive="Poker.jar"
    width=300
    height=300>
</applet>

I've tried to replace the applet code with "Poker.class", Poker.class, and "Poker". Those variations give slightly different error messages on the java console when I load the webpage where the difference is just the class name that it can't find. The error message is copied below.

I've searched sites trying to find the answer, but nothing has helped. If you have any insights, it would be very much appreciated. Thanks

Java Plug-in 1.6.0_22
Using JRE version 1.6.0_22-b04 Java HotSpot(TM) Client VM
User home directory = C:\Users\Matt
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
load: class Poker not found.
java.lang.ClassNotFoundException: Poker
    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)
Caused by: java.io.IOException: open HTTP connection failed:https://files.nyu.edu/mbn247/public/Poker.class
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
    at sun.plugin2.applet开发者_如何学编程.Applet2ClassLoader.access$000(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 9 more
Exception: java.lang.ClassNotFoundException: Poker


Ahhhh, I finally found the answer. For those who may be in the same predicament:

You must specify the package name in the code param. So, my package is called "poker", the class is "Poker.class" and my html should look like this:

<applet code="poker.Poker.class"
    archive="Poker.jar"
    width=300
    height=300>
</applet>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜