views:

51

answers:

2

I've been looking into putting a little Java application in my web page, but the more research I do, the more confused I become about how I should do it. Sun suggests many ways of doing it, but it looks suspiciously like it's from the Netscape era.

So, should I use <applet>, as suggested by eclipse, <embed>, or <object>?

And how should I use the correct tag?

A: 

Well if you want to strictly follow standards then a quick look here at the W3C standards says that applet is depreciated and you should use object instead.

TheLQ
Exactly how are you supposed to use the `<object>` tag for including java applets?
Eric
Don't you mean deprecated?
Eric
@Eric: I get depreciated and deprecated confused, sorry. And yes, you can use object: http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross-browser-standards-compliant-pure-html-deployment-using-the-object-tag . Scroll down to "A Better Way: Deployment with the <object> Tag". However the solution by Dougnukem is much better
TheLQ
+1  A: 

Since Java 6 Update 10 they've released a Java Deployment Kit:

The Java Deployment Toolkit makes deploying Java applets or Java Web Start programs a snap. The Deployment Toolkit JavaScript file provides:

* Accurate detection of installed JREs
* Seamless JRE installation
* Complete applet launching (JRE detection and, if necessary, upgrading) 
  in a single line of code
* Complete Web Start program launching in a single line of code 

The following HTML code is all it takes to ensure that Java 1.6 is installed and then a Java applet is launched:

<script src="http://java.com/js/deployJava.js"&gt;&lt;/script&gt;

<script>
  deployJava.runApplet({codebase:"http://www.example.com/applets/",
     archive:"ExampleApplet.jar", code:"Main.class",
     width:"320", Height:"400"}, null, "1.6");
</script>
Dougnukem