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

前端 未结 7 1692
南方客
南方客 2020-12-02 14:50

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 somebod

相关标签:
7条回答
  • 2020-12-02 15:02

    If you can target Java 6 update 10 or better, you can simplify your life:

    <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>
    
    0 讨论(0)
  • 2020-12-02 15:03

    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.

    0 讨论(0)
  • 2020-12-02 15:04

    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.

    0 讨论(0)
  • 2020-12-02 15:10

    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!

    0 讨论(0)
  • 2020-12-02 15:16

    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. 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.

    0 讨论(0)
  • 2020-12-02 15:19

    There is a section in The Java Tutorials titled Using applet, object and embed Tags which addresses the issue.

    From the General Considerations:

    Deploying Applets on the Internet Versus an Intranet

    When deploying applets:

    • Use the applet tag if the Web page is accessed through the Internet.
    • Use the object or embed tag if the Web page is accessed through an Intranet.

    Deploying Applets for Specific Browsers

    When deploying applets:

    • For Internet Explorer only, use the object tag.
    • For the Mozilla family of browsers only, use the embed tag.

    If you must deploy an applet in a mixed-browser environment, follow the guidelines in the section Deploying Applets in a Mixed-Browser Environment.

    It should be noted that the applet tag has been deprecated, so it's probably not desirable to use that tag. (More information on the applet tag from the W3C)

    (Note: Links have been updated from the previous edit to link to The Java Tutorials.)

    0 讨论(0)
提交回复
热议问题