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 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
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 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>
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
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.)
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
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.
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.
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.
deployJava.js
script, it is disappointing to see you hauling out all these old answers to give the same (outdated) advice. –
Loney © 2022 - 2024 — McMap. All rights reserved.