我在从 appletviewer 或从我创建的 html 文件运行程序时遇到困难。我可以很好地运行我编译的 .class 文件,并且 eclipse 会生成我的图像,但我无法在 eclipse 之外重新创建它。我所有的文件也都在同一个目录中。
广告Applet.html:
<html>
<head>
<title>AdvertisementApplet</title>
</head>
<body>
<center>
<applet code=”AdvertisementApplet.class” width="400" height="300"></applet>
</center>
</body>
</html>
广告Applet.java:
import javax.swing.JApplet;
import java.awt.*;
public class AdvertisementApplet extends JApplet{
public void paint (Graphics page){
page.setColor(Color.cyan);
page.drawRect (50, 50, 40, 40);
page.drawRect (80, 60, 40, 40);
page.drawOval (50, 50, 40, 40);
page.drawLine (50, 50, 40, 40);
page.drawString("out of clutter, find simplicity.", 110, 70);
page.drawString("—Albert Einstein", 130, 100);
}
}
错误信息:
load: class ”AdvertisementApplet.class” not found.
java.lang.ClassNotFoundException: ”AdvertisementApplet.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: ”AdvertisementApplet.class”