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 somebody have any resources on that? i cant find any :(
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 somebody have any resources on that? i cant find any :(
There is a section in The Java Tutorials titled Deploying Applets which addressed the issue.
From the General Deployment 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
orembed
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.)
If you have the luxury of targeting 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>
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.
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!
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