//<applet code=FirstApplet width=100 height=100>
//</applet>
package com.davidflanagan.examples.applet;
import java.applet.*; // Don't forget this import statement!
import java.awt.*; // Or this one for the graphics!
/** This applet just says "Hello World! */
public class FirstApplet extends Applet {
// This method displays the applet.
public void paint(Graphics g) {
g.drawString("Hello World", 25, 50);
}
}
输出如下:
E:\java>appletviewer FirstApplet.java
载入:找不到类 FirstApplet。
java.lang.ClassNotFoundException: FirstApplet
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:168)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:119)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:599)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:712)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:641)
at sun.applet.AppletPanel.run(AppletPanel.java:320)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.FileNotFoundException: E:\java\FirstApplet.class (系统找不到
指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection
.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon
nection.java:161)
at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:280)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:44)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:158)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:155)
... 8 more
谁能告诉我是为什么吗?