我在 NetBeans 中制作了一个非常简单的小程序查看器。然后我制作了一个 HTML 文件来调用那个“.class”文件。.class 和 HTML 文件都存储在同一个文件夹中。但是一旦我在我的网络浏览器(我尝试使用所有常见的浏览器)中运行 HTML 文件(在我的本地主机中),它就无法显示小程序。它显示了我附加的错误。
[注意:我也尝试在公共域中上传我的虚拟主机服务中的文件,但它显示相同的错误。]
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package stringpractice;
import java.awt.*;
import java.applet.*;
import javax.swing.*;
/**
*
* @author
*/
public class Applet extends JApplet {
public void paint(Graphics g){
super.paint(g);
System.out.println();
g.drawString(" Hello", 50, 50);
}
}
.HTML:
<html>
<title>Applet Viewer</title>
<body>
<applet code="Applet.class" width="300" height="300">
</applet>
</body>
</html>