简体   繁体   English

如何为今天的浏览器(applet,embed,object)部署java applet?

[英]How to deploy a java applet for today's browsers (applet, embed, object)?

How do i deploy a java applet for modern browsers? 如何为现代浏览器部署Java applet? 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 :( 我找不到任何:(

If you can target Java 6 update 10 or better, you can simplify your life : 如果您可以针对Java 6更新10或更高版本,您可以简化您的生活

<script src="http://java.com/js/deployJava.js"></script>
<script>
    var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D',
                      code:'java2d.Java2DemoApplet.class',
                      archive:'Java2Demo.jar',
                      width:710, height:540} ;
    var parameters = {fontSize:16} ;
    var version = '1.6' ;
    deployJava.runApplet(attributes, parameters, version);
</script>

There is a section in The Java Tutorials titled Using applet, object and embed Tags which addresses the issue. “Java教程 ”中有一节标题为使用applet,object和embed标签来解决这个问题。

From the General Considerations : 一般考虑因素

Deploying Applets on the Internet Versus an Intranet 在Internet上与Intranet部署Applet

When deploying applets: 部署applet时:

  • Use the applet tag if the Web page is accessed through the Internet. 如果通过Internet访问网页,请使用applet标记。
  • Use the object or embed tag if the Web page is accessed through an Intranet. 如果通过Intranet访问网页,请使用objectembed标记。

Deploying Applets for Specific Browsers 为特定浏览器部署Applet

When deploying applets: 部署applet时:

  • For Internet Explorer only, use the object tag. 仅适用于Internet Explorer,请使用object标记。
  • For the Mozilla family of browsers only, use the embed tag. 仅适用于Mozilla系列浏览器,请使用embed标记。

If you must deploy an applet in a mixed-browser environment, follow the guidelines in the section Deploying Applets in a Mixed-Browser Environment . 如果必须在混合浏览器环境中部署applet ,请遵循“ 在混合浏览器环境中部署Applet”一节中的准则。

It should be noted that the applet tag has been deprecated, so it's probably not desirable to use that tag. 应该注意的是, applet标签已被弃用,因此可能不希望使用该标签。 ( More information on the applet tag from the W3C ) 有关W3C的applet标签的更多信息

(Note: Links have been updated from the previous edit to link to The Java Tutorials.) (注意:链接已从上一个编辑更新为链接到Java教程。)

Use deployJava.js -- even if you AREN'T targeting only 1.6 and above. 使用deployJava.js - 即使您不是仅针对1.6及更高版本。 I've been using it for more than a year, with applets that still support even the MSJVM (Java 1.1). 我已经使用它超过一年了,applet仍然支持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! 旧版JRE的脚本中有许多功能,但它仍然非常有用!

Well, be aware that deployJava.js is designed to be called at document load time. 好吧,请注意deployJava.js旨在在文档加载时调用。 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. 因此,如果你动态地插入applet,在一个事件之后,在构建DOM之后,你会对这种新的标准方法感到不快。 We had to use the object/embed/noembed construct. 我们必须使用object / embed / noembed构造。

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 编辑 :哦,有人找到了更好的方法,但这需要手动更改SUN的原始deployJava.js,请参阅以下链接: Java Plug-In - deployJava.js的重要补充

deployJava.js has many serious lacks. deployJava.js有很多严重缺陷。

Read my write-up on deployJava.js on Oracles Java-forum. 阅读我在Oracles Java论坛上关于deployJava.js的文章。

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. (最好使用MercurialBitBucket上 。)如果是这样,请对此进行评论,并直接与我联系。

The below should work cross browser:- 以下应该跨浏览器工作: -

<p>
<object type="application/x-java-applet"
    name="accessName" width="300" height="200">
    <param name="code" value="className" />
    <param name="archive" value="jarName.jar" />
    <param name="scriptable" value="true" />
    <param name="mayscript" value="true" />
</object>
</p>

In my tests both IE8 and FF5 required the "type" attribute. 在我的测试中,IE8和FF5都需要“type”属性。 Any object classid attribute caused Firefox to fail. 任何对象classid属性都会导致Firefox失败。 The mayscript param will be ignored by Java plugins after 1.6.0.10. 在1.6.0.10之后,Java插件将忽略mayscript参数。 The scriptable param is still required according to javadocs 1.6.0.21. 根据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. 在1.6.0.24的测试中,对于已签名的applet,IE8在没有脚本化设置为真的情况下从JS调用它。

You might consider using Java Web Start instead of an applet if you are making an application. 如果要创建应用程序,可以考虑使用Java Web Start而不是applet。 Applets are used only if are creating something that has to be shown in a browser. 只有在创建必须在浏览器中显示的内容时才使用小程序。

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

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