Rolls-Royce 部署 Java applet 的方法是什么?

发布于 2024-07-24 12:26:13 字数 1227 浏览 6 评论 0原文

我知道如何使用 appletobjectembed 标签和 JavaScript 部署小程序,但我想要最佳方法(就最终用户体验而言)。

Sun 建议使用applet 标记 和 混合嵌入 /同一页面上的对象标记

我正在考虑的是:

  1. 跨浏览器支持。
  2. 如果发现不正确的 Java 版本(例如 1.5 之前的版本),则返回到下载页面。
  3. Java VM 启动期间和下载 Jar 时的加载页面(最好是带有进度条的自定义启动屏幕)。

之前已提出问题:如何部署检查 1.6插件框架< /a>. 这些都没有完全回答我的问题。 我也没有考虑 Web Start 或 Java FX。

我当前的解决方案是包含一个为 Java 1.1 编译的附加小测试小程序。 如果找到 Java 1.5 之前的版本,则会将页面重定向到失败页面。 如果未找到 Java,页面会要求用户访问 java.com。 这可以接受,但效果很差,因为它需要额外的小程序,并且在虚拟机启动时不显示任何内容。

I know how to deploy an applet using applet, object, embed tags and JavaScript, but I'm after the best approach (in terms of end user experience).

Sun suggests using the applet tag, and a mixed embed / object tag on the same page.

What I am considering is the following:

  1. Cross-browser support.
  2. Fallback to download page if incorrect Java version is found (eg pre 1.5).
  3. Loading page for both Java VM start period and while the Jar is downloaded (ideally a custom splash screen with a progress bar).

Questions have been asked before: how to deploy, check for 1.6, and Plugin framework. None of these fully answer my question. I am also not considering web start or Java FX.

My current solution is to include an additional small test applet compiled for Java 1.1. If Java pre-1.5 is found it redirects the page to the failure page. If no Java is found the page asks the user to visit java.com. This works acceptably, but is poor because it requires an additional applet and doesn't show anything while the VM is starting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

从﹋此江山别 2024-07-31 12:26:13

经过与网络上旧的和过时的信息的大量斗争之后,似乎实际上有一种非常简单的方法来部署小程序 - 只需让 Sun 为您编写正确的标签即可!

<script src="http://java.com/js/deployJava.js"></script>
<script>
  var attributes = {
    code:'java2d.Java2DemoApplet.class',
    archive:'Java2Demo.jar',
    width:710, 
    height:540
  };
  var parameters = {
    fontSize:16
  };
  var version = '1.6' ; // whichever minimum version you want to target, null works also
  deployJava.runApplet(attributes, parameters, version);
</script>

对我来说,它就像一个跨浏览器的魅力,如果没有安装java,它会自动重定向到下载页面。

更多信息请参见:

http://java.sun .com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit

After much struggling with old and outdated information all over the web it seems like there's actually a really easy way to deploy applets - just let Sun write the correct tags for you!

<script src="http://java.com/js/deployJava.js"></script>
<script>
  var attributes = {
    code:'java2d.Java2DemoApplet.class',
    archive:'Java2Demo.jar',
    width:710, 
    height:540
  };
  var parameters = {
    fontSize:16
  };
  var version = '1.6' ; // whichever minimum version you want to target, null works also
  deployJava.runApplet(attributes, parameters, version);
</script>

Worked like a charm, cross-browser, for me, with auto redirection to download page if java's not installed.

More info here:

http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit

仙女山的月亮 2024-07-31 12:26:13

请参阅 PulpCore 的解决方案(许可证:BSD)。

一个例子:Milpa 游戏...现在,如果我见过的话,那就是劳斯莱斯小程序部署。

而且——绝对同意,Sun 的部署工具包非常需要处理禁用的 Java——目前它似乎完全忽略了这一点。

See PulpCore's solution (license: BSD).

An example: the Milpa game... now, that's Rolls-Royce applet deployment if I ever saw it.

And -- absolutely agreed, Sun's Deployment Toolkit sorely needs to handle disabled Java -- it seems to ignore that entirely, currently.

贵在坚持 2024-07-31 12:26:13

我发现 JavaScript 是最好的解决方案。 对于 IE,编写对象标记并通过 classid 属性,对于其他所有内容,带有 type="application/x-java-applet;version=1.5" 的嵌入标签效果很好。 两者都使用内置的浏览器机制来应对过时(或完全缺乏)的 java.lang.

您还可以做一些奇特的事情,例如指定 1.5.0 作为最低版本,但设置 自动下载到 1.6,因此任何没有 java 的人都可以获得最新的 JRE,而不是 1.5。

我从事的项目多年来一直在推出我们自己的跨平台 JS 包装器,但随着 Java 6 update 10 Sun 创建了 deployJava.js 旨在为您解决所有这些问题。

I find JavaScript to be the best solution. For IE, write an object tag and control the exact minimum version of the JRE through the classid attribute, for everything else an embed tag with type="application/x-java-applet;version=1.5" works just fine. Both use the built-in browser mechanisms for coping with an out of date (or complete lack of) java.

You can also do fancy things like specify 1.5.0 as the minimum version, but set the auto-download to 1.6 so anyone without java gets the latest JRE instead of 1.5.

The project I work on has rolled our own cross-platform JS wrapper for many years, but with Java 6 update 10 Sun created deployJava.js which aims to solve all of these problems for you.

手心的海 2024-07-31 12:26:13

+1 to pool for applet-fu 在 chrome、FF、IE 6、7、8 上为我工作。
我不认为它能比这里更劳斯莱斯:

http://products.metamolecular.com/2009/06/08/better-applet-deployment-with-applet-fu
http://github.com/metamolecular/applet-fu

看起来非常简单,也没有太多文档。 但这就是美丽!

applet_fu.run(
  {'width':'550','height':'320'},
  {
    'archive':'myapplet.jar',
    'code':'com/example/MyApplet.class',
    'foo':'bar'
  },
  '1.4.2',
  '<img src="/no-java.png" />'
);

是的,没错,如果没有找到小程序,您可以打入 html 来显示。
1.4.2部分是要检查的最低版本,如果发现较低版本,仍然会显示no java。 foo : bar 是参数的一个示例。

+1 to pool for applet-fu worked for me on chrome, FF, IE 6,7,8.
I don't think it can get more rolls royce than this here:

http://products.metamolecular.com/2009/06/08/better-applet-deployment-with-applet-fu
http://github.com/metamolecular/applet-fu

Seems like an absolutely simple thing, there isn't much documentation either. But thats the beauty!!

applet_fu.run(
  {'width':'550','height':'320'},
  {
    'archive':'myapplet.jar',
    'code':'com/example/MyApplet.class',
    'foo':'bar'
  },
  '1.4.2',
  '<img src="/no-java.png" />'
);

Yes thats right, you can slap in html to display if the applet isn't found.
The 1.4.2 part is the minimum version to check for, if a lower version is found it will still show no java. foo : bar is an example of params.

掌心的温暖 2024-07-31 12:26:13

我强烈建议不要部署Java.js。
我怀疑它是否在任何地方进行过测试。
看看它的代码:

s = '<param name="' + parameter + '" value="' + 
                parameters[parameter] + '">';

它没有关闭标签! Chrome 对此完全感到窒息,给出了“未捕获的错误:INVALID_STATE_ERR:DOM 异常 11”! 更不用说使用 document.write 了,你必须用这样的东西来克服 Java Plug- In - 对deployJava.js 的重要补充

注册只是为了告诉大家这一点,因为前几天我花了四个小时完全沮丧地处理这个问题:(

I would strongly recommend against deployJava.js.
I doubt it was tested anywhere.
Just look at its code:

s = '<param name="' + parameter + '" value="' + 
                parameters[parameter] + '">';

It doesn't close the tag! And Chrome chokes on this completely giving me "Uncaught Error: INVALID_STATE_ERR: DOM Exception 11"! Not to mention the use of document.write which you have to overcome with stuff like this Java Plug-In - Important addition to deployJava.js.

Registered just to tell this, as I spent four hours in complete frustration dealing with this the other day :(

久夏青 2024-07-31 12:26:13

为了获得最佳的跨浏览器兼容性,您应该遵循 SUn 的建议,特别是使用混合嵌入/对象标记。 它很丑,但可以为您提供最佳的覆盖范围。

For best cross-browser compatibility, you should follow SUn's advice, particularly the use of mixed embed/object tags. It's ugly, but gives you the best coverage.

浪漫人生路 2024-07-31 12:26:13

考虑在起始页上有一个小小程序,它告诉浏览器转到真正的小程序页面。

在起始页上,还有一个“您可以在此处获取 Java”链接。

根据我的经验,讨厌的 javascript 提供了讨厌的支持:(

另请注意,Java 6 u 10 可以使用 Java WebStart 来部署 Applet。如果您的用户使用此版本或更高版本,这可能会带来更好的用户体验。

Consider having a small applet on the start page, which tells the browser to go to the real applet page.

On the start page, also have a "You can get Java here" link.

In my experience, nasty javascript gives nasty support :(

Also note that the Java 6 u 10 can use Java WebStart to deploy Applets. This might be a nicer user experience if your users have this version or later.

来世叙缘 2024-07-31 12:26:13

您好,只需使用对象标签即可。 它是 HTML 规范的一部分,适用于大多数浏览器。

安装选项的后备方案只是在标签中写入一些文本。

这是关于该主题的一篇有用的文章:

http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross -浏览器标准兼容-pure-html-deployment-using-the-object-tag

问候

Hi just use the object tag. It's part of the HTML specification and works with most browsers.

The fallback with installation option is just writing some text in the tag.

Here is a usefull article on the subject:

http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross-browser-standards-compliant-pure-html-deployment-using-the-object-tag

Regards

近箐 2024-07-31 12:26:13

请注意,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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文