简体   繁体   English

HTML Java applet集成

[英]HTML Java applet integration

I know this has been asked multiple times already, and I have already tried to use all of the solutions that I could find, but I wasn't able to get any success. 我知道这已被要求多次已经和我已经尝试使用所有我能找到的解决方案,但我没能获得任何成功。 I have a JApplet that works successfully (I've pasted the heirarchy below, as I don't think the code itself is relevant to the issue. I might be wrong). 我有一个成功运行的JApplet(我在下面粘贴了heirarchy,因为我认为代码本身并不与问题相关。我可能错了)。 I also have some basic HTML code that seems to be correct based on the solutions that I have found. 根据我找到的解决方案,我还有一些基本的HTML代码似乎是正确的。 The problem is that I continue to get the same error: 问题是我继续得到同样的错误:

错误
(source: gyazo.com ) (来源: gyazo.com

And I'm not sure why I'm getting it. 我不知道为什么我会得到它。 Is it because everything in the heirarchy is a .java file? 是因为heirarchy中的所有内容都是.java文件吗?

my HTML file: 我的HTML文件:

<html>
    <head></head>
        <body>
            <applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class"></applet>
        </body>
</html>

Hierarchy: 层次:

等级制度

Files: 文件:

档

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks so much! 非常感谢!

First, you need to close you <head> tag with </head> and do the same with the <body> tag. 首先,您需要使用</head>关闭<head>标记,并对<body>标记执行相同操作。

Also, the <applet> tag has been deprecated in HTML4.01 and is not allowed in HTML5, so you should replace for <object> tag 此外, <applet>标记已在HTML4.01中弃用 ,HTML5中不允许使用,因此您应该替换<object>标记

So, if you are using it on Chrome, for instance. 因此,如果您在Chrome上使用它,例如。 It will NOT work. 不起作用。

你能试一下吗..

<applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class">

If your applet is in the same dir. 如果你的applet在同一个目录中。 as the html file you don't need to specify it as the browser searches for a location of the document in the same dir, if you have it elsewhere then it's ok to have the archive which should containt the path to the jar file. 作为html文件,您不需要指定它,因为浏览器在同一目录中搜索文档的位置,如果您在其他地方有它,那么可以使用包含jar文件路径的存档。

Beside that you should consider adding to the code attribute also the package in which your class resideds, all separated by a dot code="OneQuestMapgen.OneQuestMapgen.class" 除此之外,你应该考虑在代码属性中添加你的类所在的包,所有这些都用点code="OneQuestMapgen.OneQuestMapgen.class"

Shouldn't your html be like this? 你的HTML应该不是这样吗?

<html>
<head></head> <!-- closing the head before the body -->
<body>
  <applet width="950" height="600" code="OneQuestMapgen.OneQuestMapgen.class" 
    type="application/x-java-applet;jpi-version=6" 
    archive="test.jar">
</body>
</html>

in html5 it should be something like 在html5中应该是这样的

<object type="application/x-java-applet" height="600" width="950">
  <param name="code" value="OneQuestMapgen.OneQuestMapgen.class" />
  <param name="archive" value="test.jar" />
  Applet failed to run.  No Java plug-in was found.
</object>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM