[英]How to load a Java applet class from a subfolder with the embed tag?
I have a Java Applet as a single class file (No JAR file) in some sub directory and I want to embed it on a HTML page which is in a different directory. 我在某个子目录中有一个Java Applet作为单个类文件(没有JAR文件),我想将其嵌入在另一个目录中的HTML页面上。 And I want to use the
embed
tag for it. 我想使用
embed
标签。 But I can't get it working. 但是我无法正常工作。 This is my code so far:
到目前为止,这是我的代码:
<embed type="application/x-java-applet;version=1.6"
width="512" height="512"
code="subfolder/MyApplet.class" />
According to the Apache log file the Class file is loaded but it can't be started. 根据Apache日志文件,Class文件已加载,但无法启动。 Java says there is no class with name
subfolder.MyApplet
. Java表示没有名称为
subfolder.MyApplet
类。 So it treats the sub directory as a package name. 因此,它将子目录视为程序包名称。 A
codebase
parameter (No idea if this is valid for embed
) doesn't make a difference. 一个
codebase
参数(不知道这是否对embed
有效)没有任何区别。 Maybe there is some other badly documented parameter to specifiy a code base directory from which to load the classes? 也许还有一些其他文档记录不充分的参数来指定从中加载类的代码库目录?
Please note that my question is not about how to embed a Java applet in general. 请注意,我的问题不是关于一般如何嵌入Java applet的。 I know how to get it running with the deprecated
applet
tag or the object
tag and by packaging the class into a JAR file. 我知道如何通过不推荐使用的
applet
标签或object
标签以及将类包装到JAR文件中来使其运行。 My question is how to get it working in exactly this specific situation: 我的问题是如何在特定情况下使其正常工作:
embed
tag. embed
标签。 Consider using the 'codebase' tag when using the 'embed' tag. 使用“嵌入”标签时,请考虑使用“代码库”标签。 For example,
例如,
<embed type="application/x-java-applet;version=1.6"
width="512" height="512"
code="MyApplet.class"
codebase="subfolder/"/>
You should be able to use relative and absolute paths in the 'codebase' tag. 您应该能够在'codebase'标签中使用相对和绝对路径。
Hope that helps... 希望有帮助...
Try following: 尝试以下操作:
<embed type="application/x-java-applet;version=1.6"
width="512" height="512"
codebase="subfolder/"
code="MyApplet.class" />
Refer to this documentation . 请参阅本文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.