开发者

Java applets contained in packages

Can I have an applet live in a package? ie:

bfwd.RedemptionOnline.client

would be the package, and RedemptionOnlineApplet.class would live inside that package. If you can, how would you create the tag for it if it lived inside RedemptionOnline.jar?

here is the tag i'm using:

<applet code="bfwd/RedemptionOnline/client/RedemptionOnlineApplet" width="1" height="1" archive="RedemptionOnline.jar">
    <PARAM NAME="MAYSCRIPT" VALUE="true">
</applet>

and here is a log of the error i'm getting:

Java Plug-in 10.0.0.147
Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM
User home directory = C:\Users\LordZardeck
----------------------------------------------------
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>
----------------------------------------------------
basic: Added progress listener: sun.plugin.util.ProgressMonitorAdapter@1b1a66b
basic: Plugin2ClassLoader.addURL parent called for http://localhost/redemption/RedemptionOnline.jar
network: Cache entry found [url: http://localhost/redemption/RedemptionOnline.jar, version: null] prevalidated=false/0
network: Connecting http://localhost/redemption/RedemptionOnline.jar with proxy=DIRECT
network: Connecting http://localhost:80/ with proxy=DIRECT
network: Connecting http://localhost/redemption/RedemptionOnline.jar with cookie "PHPSESSID=loub2i9mprilg7ihvjn8g960v1"
network: ResponseCode for http://localhost/redemption/RedemptionOnline.jar : 304
network: Encoding for http://localhost/redemption/RedemptionOnline.jar : null
network: Disconnect connection to http://localhost/redemption/RedemptionOnline.jar
cache: Reading Signers from 5 http://localhost/redemption/RedemptionOnline.jar | C:\Users\LordZardeck\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\4\40bb90c4-62ab3bc6.idx
network: No certificate info for unsigned JAR file: http://localhost/redemption/RedemptionOnline.jar
cache:  Read manifest for http://localhost/redemption/RedemptionOnline.jar: read=82 full=82
network: Cache entry not found [url: http://localhost/redemption/, version: null]
network: Cache entry not found [url: http://localhost/redemption/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class, version: null]
network: Connecting http://localhost/redemption/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class with proxy=DIRECT
network: Connecting http://localhost/redemption/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class with cookie "PHPSESSID=loub2i9mprilg7ihvjn8g960v1"
network: Cache entry not found [url: http://localhost/redemption/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class, version: null]
network: Connecting http://localhost/redemption/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class with proxy=DIRECT
network: Connecting http://localhost/redemption/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class with cookie "PHPSESSID=loub2i9mprilg7ihvjn8g960v1"
java.lang.ClassNotFoundException: bfwd.RedemptionOnline.client.RedemptionOnlineApplet
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at开发者_JS百科 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.initAppletAdapter(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
basic: load: class bfwd/RedemptionOnline/client/RedemptionOnlineApplet not found.
java.lang.ClassNotFoundException: bfwd.RedemptionOnline.client.RedemptionOnlineApplet
    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.initAppletAdapter(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@1b1a66b
security: Reset deny session certificate store


If your Applet class is packaged inside a JAR file which is downloadable by http://example.com/RedemptionOnline.jar, then you should specify the packaged class' full qualified name in code and the (relative) public web URL of the JAR file in archive (note: case sensitive!):

<applet code="bfwd.RedemptionOnline.client.RedemptionOnlineApplet" archive="RedemptionOnline.jar">

(I agree with Jon that package names should be lowercased, conform Java Naming Conventions)

If your Applet class is just a loose .class file in public web content which is downloadable by http://example.com/bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class, then you should specify exactly its (relative) public web URL in code instead (note: also case sensitive!):

<applet code="bfwd/RedemptionOnline/client/RedemptionOnlineApplet.class">

Do you now understand when to use periods and when to use slashes and when to suffix .class?


Yes, applets can be in packages - although I would advise you to follow conventions and name the package something like

com.bfwd.redemptiononline.client

When you create the tag, you'd just specify the fully-qualified name:

com.bfwd.redemptiononline.client.RedemptionOnlineApplet.class

or possibly (documentation varies and it's a long time since I've done any applet work)

com.bfwd.redemptiononline.client.RedemptionOnlineApplet

or even:

com/bfwd/redemptiononline/client/RedemptionOnlineApplet.class
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜