我有一个applet jar文件cia.jar
以及其中的类main.class
,我的包在com.gmail.connorbphtml.WebApp
包中。我正在尝试将我的applet嵌入到网页中。当我尝试这样做时,我得到一个类未找到错误。
applet在Eclipse中运行良好但是当我尝试嵌入它时它不起作用。
这是我使用embed的HTML:
<embed code="main.class"
archive="cia.jar"
width="200" height="200"
type="application/x-java-applet;version=1.6.0"
pluginspage="http://java.sun.com/javase/downloads"/>
我几个月来一直遇到这个问题,这让我放弃了小程序,因为我无法让这个工作。
有谁知道出了什么问题?
jar -tvf cia.jar
的结果是:
39 Sun Sep 16 12:34:50 EDT 2012 META-INF/MANIFEST.MF
0 Sat Sep 15 18:02:30 EDT 2012 com/
0 Sat Sep 15 18:02:30 EDT 2012 com/gmail/
0 Sat Sep 15 18:02:30 EDT 2012 com/gmail/connorbphtml/
0 Sat Sep 15 18:02:30 EDT 2012 com/gmail/connorbphtml/WebApp/
136 Sat Sep 15 18:02:16 EDT 2012 com/gmail/connorbphtml/WebApp/package-info.class
692 Sat Sep 15 23:26:08 EDT 2012 com/gmail/connorbphtml/WebApp/main.class
226 Sat Sep 15 18:01:20 EDT 2012 .classpath
366 Sat Sep 15 18:01:20 EDT 2012 .project
控制台中的错误:
Java Plug-in 1.6.0_33
Using JRE version 1.6.0_33-b03-424-11M3720 Java HotSpot(TM) 64-Bit Server VM
User home directory = /Users/Connor
----------------------------------------------------
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>
----------------------------------------------------
Java Plug-in 1.6.0_33
Using JRE version 1.6.0_33-b03-424-11M3720 Java HotSpot(TM) 64-Bit Server VM
User home directory = /Users/Connorload: class Sun_Microsystems_Java_Security_Update_6.class not found.
java.lang.ClassNotFoundException: Sun_Microsystems_Java_Security_Update_6.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
load: class com/gmail/connorbphtml/WebApp/main.class not found.
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
load: class com/gmail/connorbphtml/WebApp/main.class not found.
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: Sun_Microsystems_Java_Security_Update_6.class
java.lang.ClassNotFoundException: com.gmail.connorbphtml.WebApp.main.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: com.gmail.connorbphtml.WebApp.main.class
java.lang.ClassNotFoundException: com.gmail.connorbphtml.WebApp.main.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: com.gmail.connorbphtml.WebApp.main.class
答案 0 :(得分:1)
使用deployJava.js
与write the element for the applet。
E.G。改编自页面:
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {codebase:'.',
code:'com.gmail.connorbphtml.WebApp.main',
archive:'cia.jar',
width:200, height:200};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
脚本将以正确的形式为正在运行的浏览器/操作系统编写相应的元素。
答案 1 :(得分:0)
代码不应包含.class
扩展名。试试这个。
<applet code="com.gmail.connorbphtml.WebApp.main" archive="cia.jar"
width="200" height="200"></applet>
此外,您未在package
属性中添加code
名称。