简体   繁体   English

Java Applet无法加载

[英]Java applet won't load

I am building a small applet in java. 我正在用Java构建一个小applet。 It works fine (really!) when I run it in eclipse as an applet. 当我在eclipse中将其作为applet运行时,它可以正常工作(真的!)。 Problems start when I export it as a jar and than try to load it through an html page. 当我将其导出为jar并尝试通过html页面加载时,问题开始了。 Here's the html code: 这是html代码:

<body>

<applet  archive="myJar.jar" width=650 height=850>

</applet>
</body>

Now when I run other jar files in this way they work fine, for example if you view the source page of this niffty demo 现在,当我以这种方式运行其他jar文件时,它们可以正常工作,例如,如果您查看此简洁演示的源页面

    <body>
    <applet code="org.niffty.Niffty.class" archive="niffty.jar" width=650 height=850>
    <param name="file" value="prelude.nif">
    </applet>
    </body>

Thank you! 谢谢!

You're missing the code attribute in your applet tag. 您在applet标签中缺少了code属性。 Without it, the browser doesn't know which class in your JAR file is the applet it should display. 没有它,浏览器将不知道它应该显示的applet在JAR文件中的哪个类。

You've specified the archive, but no code attribute so the applet runner doesn't know which class to use as the entry point. 您已经指定了档案,但是没有指定code属性,因此小程序运行器不知道将哪个类用作入口点。 You have to either specify code or specify the object attribute to give a serialized applet instance - but code is much more likely to be appropriate for you. 你必须要么指定code 指定object的属性给一个序列化的applet实例-但code是更可能适合你。

See the documentation for the applet tag for more information. 有关更多信息,请参见applet标签文档

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

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