回 帖 发 新 帖 刷新版面

主题:关于运行appler小应用程序的问题

import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet{
public void paint(Graphics g){
g.drawString("Here is the output of my program:Hello world!",50,25);
}}
这个程序运行后生成了一点class 文件  嵌入到网页中
 <applet code="HelloWorld.class" 
   width=320 height=180> 
   </applet> 


为什么在我的浏览器中不能运行呢  是不是我还要装个什么东西?

回复列表 (共4个回复)

沙发

在我的机器上可以正常运行。
你重新安装一下JAVA虚拟机试试吧。

板凳


不是JDK里面包含了java虚拟机的吗?

3 楼

换几个浏览器看看
用IE,和遨游都试试看能不能运行

4 楼

import java.applet.*  //  改成这样
import java.awt.Graphics;

public class HelloWorld extends JApplet   //这里要继承自JApplet类
{
   public void paint(Graphics g)
   {
      g.drawString("Here is the output of my program:Hello world!",50,25);
   }  
}

我来回复

您尚未登录,请登录后再回复。点此登录或注册