主题:[讨论]请问大家这个如何处理
代码如下
//HelloToJava.java
import java.awt.Graphics;
import java.applet.*;
public class HelloToJava extends Applet {
public String sHello;
public void init() {
sHello="欢迎来到Java世界!";}
public void paint(Graphics g){
g.drawString(sHello, 50, 50);}
}
以上代码运行成功了
下面的代码却出错;
<HTML>
<APPLET CODE="HelloToJava .class"
WIDTH=200 HEIGHT=100>
</APPLET>
</HTML>
错误提示:
D:\class\javaclass>javac HelloToJava.java
D:\class\javaclass>appletviewer sea.htm
载入:找不到类 HelloToJava .class。
java.lang.ClassNotFoundException: HelloToJava .class
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:626)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:760)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:689)
at sun.applet.AppletPanel.run(AppletPanel.java:361)
at java.lang.Thread.run(Thread.java:626)
Caused by: java.io.FileNotFoundException: D:\class\javaclass\HelloToJava \class.
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:295)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:44)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:173)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:170)
... 8 more
请问大家这个如何处理
//HelloToJava.java
import java.awt.Graphics;
import java.applet.*;
public class HelloToJava extends Applet {
public String sHello;
public void init() {
sHello="欢迎来到Java世界!";}
public void paint(Graphics g){
g.drawString(sHello, 50, 50);}
}
以上代码运行成功了
下面的代码却出错;
<HTML>
<APPLET CODE="HelloToJava .class"
WIDTH=200 HEIGHT=100>
</APPLET>
</HTML>
错误提示:
D:\class\javaclass>javac HelloToJava.java
D:\class\javaclass>appletviewer sea.htm
载入:找不到类 HelloToJava .class。
java.lang.ClassNotFoundException: HelloToJava .class
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:626)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:760)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:689)
at sun.applet.AppletPanel.run(AppletPanel.java:361)
at java.lang.Thread.run(Thread.java:626)
Caused by: java.io.FileNotFoundException: D:\class\javaclass\HelloToJava \class.
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:295)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:44)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:173)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:170)
... 8 more
请问大家这个如何处理