大家好!我用NetBeans编写了一个applet,构建项目后,生成的.class文件位于项目文件夹的build/classes子目录下。
我在项目文件夹根目录中写了一个HTML,包含.class文件,代码如下
<html>
<head>
<title>My First Applet</title>
</head>
<body>
<applet code="file:///F:/NetBeansProjects/Exercise_1_7/build/classes/FirstApplet.class" width="160" height="30"></applet>
</body>
</html>
用appletviewer来查看html文件时,报错了:
我把class文件拷到和html同级的根目录中,将html的applet标签的code的值直接改成class的文件名,即:
code="FirstApplet.class"
这样就好了。
但是,这样使用的是我拷出来的class文件,如果我想使用原位置的class文件,code属性的值该怎么写呢?
我尝试使用相对路径,即code="./build/classes/FirstApplet.class",依然不行。
谢谢大家!