当前位置: 代码迷 >> J2SE >> 简单的Applet程序,加载失败,该怎么处理
  详细解决方案

简单的Applet程序,加载失败,该怎么处理

热度:357   发布时间:2016-04-24 17:03:50.0
简单的Applet程序,加载失败
import   java.util.*;
import   java.awt.*;
import   java.applet.*;
import   java.text.*;
public   class   MyTest   extends   Applet
{
String   s1,s2,s3,s4;
public   void   init()
{
s1   =   getParameter( "p1 ");
s2   =   getParameter( "p2 ");
s3   =   getParameter( "p3 ");
s4   =   getParameter( "p4 ");
}
public   void   paint(Graphics   g)
{
g.drawString(s1,10,10);
g.drawString(s2,10,30);
g.drawString(s3,10,50);
g.drawString(s4,10,70);
}
}


<HTML>
    <HEAD>
        <TITLE> Applet   Parameter   Test </TITLE>
    </HEAD>
        <Applet   code=“MyTest.class "   width=300   height=300>
        <param   name=p1   value= "1111111 ">
        <param   name=p2   value= "2222222 ">
        <param   name=p3   value= "3333333 ">
        <param   name=p4   value= "4444444 ">
        </applet>
</HTML>


错误说明是这样的:载入:找不到类   “MyTest.class "。
java.lang.ClassNotFoundException:   “MyTest.class "
at   sun.applet.AppletClassLoader.findClass(Unknown   Source)
at   java.lang.ClassLoader.loadClass(Unknown   Source)
at   sun.applet.AppletClassLoader.loadClass(Unknown   Source)
at   java.lang.ClassLoader.loadClass(Unknown   Source)
at   sun.applet.AppletClassLoader.loadCode(Unknown   Source)
at   sun.applet.AppletPanel.createApplet(Unknown   Source)
at   sun.plugin.AppletViewer.createApplet(Unknown   Source)
at   sun.applet.AppletPanel.runLoader(Unknown   Source)
at   sun.applet.AppletPanel.run(Unknown   Source)
at   java.lang.Thread.run(Unknown   Source)
Caused   by:   java.io.FileNotFoundException:   D:\project\Temp\“MyTest\class ".class   (系统找不到指定的路径。)
at   java.io.FileInputStream.open(Native   Method)
at   java.io.FileInputStream. <init> (Unknown   Source)
at   java.io.FileInputStream. <init> (Unknown   Source)
at   sun.net.www.protocol.file.FileURLConnection.connect(Unknown   Source)
at   sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown   Source)
at   sun.applet.AppletClassLoader.getBytes(Unknown   Source)
at   sun.applet.AppletClassLoader.access$100(Unknown   Source)
at   sun.applet.AppletClassLoader$1.run(Unknown   Source)
at   java.security.AccessController.doPrivileged(Native   Method)
...   10   more
载入:找不到类   “MyTest.class "。
java.lang.ClassNotFoundException:   “MyTest.class "
at   sun.applet.AppletClassLoader.findClass(Unknown   Source)
at   java.lang.ClassLoader.loadClass(Unknown   Source)
at   sun.applet.AppletClassLoader.loadClass(Unknown   Source)
at   java.lang.ClassLoader.loadClass(Unknown   Source)
at   sun.applet.AppletClassLoader.loadCode(Unknown   Source)
at   sun.applet.AppletPanel.createApplet(Unknown   Source)
at   sun.plugin.AppletViewer.createApplet(Unknown   Source)
at   sun.applet.AppletPanel.runLoader(Unknown   Source)