如何为当今的浏览器部署 java applet(applet、embed、object)?
如何为现代浏览器部署 Java 小程序? 我知道有 3 种可能性,但没有人告诉我更喜欢哪一种以及如何使用它们。
有人有这方面的资源吗? 我找不到任何:(
How do i deploy a java applet for modern browsers?
I know there are somehow 3 possibilities but nobody tells me which one to prefer and how to use them.
Does somebody have any resources on that? i cant find any :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您可以针对 Java 6 update 10 或更高版本,则可以 简化您的生活:
If you can target Java 6 update 10 or better, you can simplify your life:
Java 教程中有一个标题为 使用小程序、对象和嵌入标签 解决了该问题。
来自一般注意事项:
应该注意的是,
applet
标记已被弃用,因此可能不希望使用该标记。 (有关小程序
的更多信息来自 W3C 的标记)(注意:链接已从之前的编辑更新为链接到 Java 教程。)
There is a section in The Java Tutorials titled Using applet, object and embed Tags which addresses the issue.
From the General Considerations:
It should be noted that the
applet
tag has been deprecated, so it's probably not desirable to use that tag. (More information on theapplet
tag from the W3C)(Note: Links have been updated from the previous edit to link to The Java Tutorials.)
使用deployJava.js——即使您不只针对1.6及以上版本。
我已经使用它一年多了,它的小程序甚至仍然支持 MSJVM (Java 1.1)。
该脚本中有很多功能在旧版 JRE 中不可用,但它仍然非常有用!
Use deployJava.js -- even if you AREN'T targeting only 1.6 and above.
I've been using it for more than a year, with applets that still support even the MSJVM (Java 1.1).
There are plenty of features that aren't available in the script for older JREs, but it's still quite useful!
请注意,deployJava.js 设计为在文档加载时调用。 因此,如果您在构建 DOM 之后根据事件动态插入小程序,那么您对这种新标准方法有点不走运。
我们必须使用 object/embed/noembed 结构。
编辑:哦,有人找到了更好的方法,但这需要手动更改SUN原来的deployJava.js,请参阅下面的链接:
Java 插件 - 对deployJava.js 的重要补充
Well, be aware that deployJava.js is designed to be called at document load time. So if you insert applet dynamically, upon an event, after DOM has been constructed, you're kinda out of luck with this new standard approach.
We had to use the object/embed/noembed construct.
Edit: Oh, someone found a better way for this, but this required manual altering of SUN's original deployJava.js, please see the link below:
Java Plug-In - Important addition to deployJava.js
如果您正在制作应用程序,您可能会考虑使用 Java Web Start 而不是 applet。 仅当创建必须在浏览器中显示的内容时才使用小程序。
You might consider using Java Web Start instead of an applet if you are making an application. Applets are used only if are creating something that has to be shown in a browser.
deployJava.js 有许多严重的缺陷。
请阅读我在 Oracle Java 论坛上的有关部署Java.js 的文章。
我很想在这方面启动一个开源项目,但我没有启动或做任何开源项目的经验。 有人愿意帮助我开始吗?
(最好在 BitBucket 上使用 水银。)
如果是这样,请对此发表评论,并直接与我联系。
deployJava.js has many serious lacks.
Read my write-up on deployJava.js on Oracles Java-forum.
I would love to start an open source project on this, but I have no experience on starting or doing anything open source. Anybody care to help me get one started?
(Preferrably on BitBucket using Mercurial.)
If so, comment on this, and contact me directly.
以下应该可以跨浏览器工作: -
在我的测试中,IE8 和 FF5 都需要“type”属性。 任何对象 classid 属性都会导致 Firefox 失败。 1.6.0.10 之后,Java 插件将忽略 mayscript 参数。 根据 javadocs 1.6.0.21,仍然需要可编写脚本的参数。 在使用 1.6.0.24 对签名小程序进行的测试中,IE8 从 JS 调用它为 OK,而无需将 scriptable 设置为 true。
The below should work cross browser:-
In my tests both IE8 and FF5 required the "type" attribute. Any object classid attribute caused Firefox to fail. The mayscript param will be ignored by Java plugins after 1.6.0.10. The scriptable param is still required according to javadocs 1.6.0.21. In a test with 1.6.0.24 for a signed applet, IE8 called it OK from JS without scriptable being set true.