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

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.