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

7

28

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 :(

Jaquelinejaquelyn answered 12/6, 2009 at 9:11 Comment(0)
A
14

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

Allain answered 12/6, 2009 at 9:14 Comment(0)
P
23

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>
Pevzner answered 12/6, 2009 at 9:21 Comment(1)
Can't deployJava.js deploy applets for older Java versions too?Bile
A
14

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

Allain answered 12/6, 2009 at 9:14 Comment(0)
V
6

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!

Veer answered 4/12, 2009 at 22:57 Comment(0)
E
3

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

Etienne answered 23/7, 2010 at 16:16 Comment(2)
today, I had exactly the same problem. And... yeah.. I really thought about that, too, but some odd feeling in my guts tells me that this is not the correct thing to do... PLUS: deployJava.js is minified and I really don't want to de-minify it by hand (are there any tools?) Perhabs someone should do this, fix deployJava and put it on Github...Jaquelinejaquelyn
See the human readable version of the Deployment Toolkit here: java.com/js/deployJava.txtEtienne
E
1

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.

Ely answered 12/6, 2009 at 9:21 Comment(1)
unfortunately, i'll have to use an applet, because i need it to encrypt/decrypt data from an ajax call (which would also work in javascript, but ie is daaaaamn slow) so we decided to use an applet for thatJaquelinejaquelyn
D
1

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.

Dovev answered 16/3, 2011 at 11:57 Comment(3)
then we should definitely "team up", as we're always in the need of a way to deploy java applets in a cross-browser way.Jaquelinejaquelyn
Here it is - a version 1.0 of appletjs: bitbucket.org/terjedahl/appletjsDovev
And I need a solution that works without the internet, and it needs to work to add applets after the onload as well.Pillbox
I
1

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.

Inexactitude answered 27/7, 2011 at 14:32 Comment(1)
-1 Having already advised you of the 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.