写java applet程序画椭圆,不知道为什么在ie里总是加载失败,环境变量设置正确!!!从网上下载的java applet代码可以正常运行,大家帮忙看看我的代码是不是有什么需要改的地方啊,我是看了好久没有找到,在这谢谢各位了。
java applet代码:[code]
import java.awt.Graphics;
import javax.swing.*;
public class w extends JApplet
 
{
String x1,y1,w1,h1;
int x,y,w,h;
public void init()
{
x1=JOptionPane.showInputDialog("请输入横坐标");
x=Integer.parseInt(x1);
y1=JOptionPane.showInputDialog("请输入纵坐标");
y=Integer.parseInt(y1);
w1=JOptionPane.showInputDialog("请输入长度");
w=Integer.parseInt(w1);
h1=JOptionPane.showInputDialog("请输入宽度");
h=Integer.parseInt(h1);
}
public void paint(Graphics g)
{
super.paint(g);
g.drawOval(x,y,w,h);
 
}
}[code]在同一文件夹下的w.html文件代码<html>
<applet code="w.class" width="1000" height="1500">
</applet>
</html>
下面是错误,我也不知道哪里错了记录设置为:true .... 完成。
载入:找不到类 w.class。
java.lang.ClassNotFoundException: w.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)
 

解决方案 »

  1.   

    不一样的机器差别很大,applet好像容易出各种各样的问题。
      

  2.   

    不会吧,我用2台机子测试,都是不能运行,运行条件是JDK1.41 和jre6.0 ,不知道为什么,我电脑装不了jre1.4,一点java控制台就弹出应用程序错误,会不会和浏览器也有关啊??
      

  3.   

    比较明显是JRE的问题,可能是版本不支持你编译的class
      

  4.   

    但是我用系统的drawLine()函数就可以正常显示啊
      

  5.   

     applet 是会有这种怪问题的
    学习.
      

  6.   

    系统的drawLine? 即使可以,总得有一个启动的class吧,现在明显是启动的class都找不到,怎么去调drawLine呢,自己好好想一想
      

  7.   

    对于java applet  启动.class 因为没有main 函数,启动时通过一个html 文件来启动的,只要<code="*.class">包括进去就可以了,并且也确实可以用,请问还想什么啊
      

  8.   

    编译的版本与运行的版本要尽量一致,确认一下这个
    你的出错提示是没有找到类,类都找不到,又怎么可以调drawLint(),又是怎么“确实可以用”?自相矛盾,莫名其妙
      

  9.   

    就是说,一下这段代码可以正常编译运行,
    import java.awt.Graphics;    
    import javax.swing.JApplet;  
    public class WelcomeLines extends JApplet {  
       public void paint( Graphics g )
       {      super.paint( g );)
          g.drawLine( 15, 10, 210, 10 ); 
          g.drawLine( 15, 30, 210, 30 );       g.drawString( "Welcome to Java Programming!", 25, 25 );   } } 
      

  10.   

     建议你先弄明白 ClassNotFoundException 是什么
      

  11.   

    类必须在根目录下,不能在web-inf下面