Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将applet嵌入到html页面问题中_Java_Html_Path_Applet - Fatal编程技术网

Java 将applet嵌入到html页面问题中

Java 将applet嵌入到html页面问题中,java,html,path,applet,Java,Html,Path,Applet,我很难嵌入一个简单的小程序。我认为类文件名的相对/绝对路径的设置是问题所在。我尝试过很多不同的方法,但都没有成功。只有一个例外。如果我将indexApplet.html文件放在bin文件夹中,它就会工作。但是我想把indexApplet.html放在它之外。我真的很感谢你对这件事的帮助 以下是我的html代码和文件夹结构: [code] <!doctype html> <html> <head> <meta charset="utf-8"> &l

我很难嵌入一个简单的小程序。我认为类文件名的相对/绝对路径的设置是问题所在。我尝试过很多不同的方法,但都没有成功。只有一个例外。如果我将indexApplet.html文件放在bin文件夹中,它就会工作。但是我想把indexApplet.html放在它之外。我真的很感谢你对这件事的帮助

以下是我的html代码和文件夹结构:

[code]
<!doctype html>
<html>
<head>
<meta charset="utf-8">

<title>Java Game</title>

</head>

<body>

<applet code="test/bin/first/hello.class"  width="800" height="600" alt="Java Game" title="Go and Play"></applet>

</body>
</html>
[/code]
[代码]
爪哇游戏
[/code]
类文件位于:C:\Users\Valentin\workspace\test\bin\first


我希望将indexApplet.html文件放在测试文件夹之外。

假设您正在从
C:\Users\Valentin\workspace
查看小程序,并且类
hello
首先在
包中声明,然后需要添加
代码库
属性:

<applet code="first.hello.class" width="800" height="600" codebase="test/bin">

那么您已经在文件夹
C:\Users\Valentin\workspace
中获得了
indexApplet.html
,对吗?
hello
是在
第一个
包中声明的吗?这是什么意思?“宣布”。文件hello.class位于标有first的文件夹中。它是否以
package first开头?-先发布你的
hello.java
,如果它不是太大的包;导入java.applet.applet;导入java.awt.Graphics;公共类hello扩展了Applet{public void paint(Graphics g){g.drawString(“hello world!”,50,25);}}NoClassDefFoundError hello(错误名称:first/hello)