Skip to main content

What is the Rolls-Royce way to deploy a Java applet?


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.


Source: Tips4allCCNA FINAL EXAM

Comments

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

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

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

    ReplyDelete
  4. +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.

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

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

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

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

    ReplyDelete
  9. 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 :(

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex