views:

471

answers:

2

I am writing a Java applet, and would like to know the best way to include it in a web page.

I'd like it to prompt the user to install JRE if she hasn't it already. This feature should (ideally) work cross-browser on any OS Java runs on. Another requirement is that the applet should not be loaded on page load, but after a user action, not to load the JVM on every page load. I guess this is the official SUN way, but it uses document.write(), so I can't use it after the page has finished rendering.

+4  A: 

I would recommend just using the applet tag. As Alex B comments, most browsers will prompt the user to install at that point if they don't have the JRE.

Even Sun recommends using the applet tag except on Intranets unless you are on an intranet. I imagine the logic here is that you can host the JRE download on an internal server, and use the embed & object tags to direct the download to that server.

I used to use the embed & object tags, but that ends up being a hassle due to the version numbers. Lets say you require Java 1.5. So you specify that in the object & embed tags to make sure the user will have to upgrade if they don't have 1.5. However, that's not really what you want, you want it to upgrade them to the very latest JVM. In any event, it was not the smartest behavior when I last played with it-- it's possible they have improved it now.

larson4
A: 
Pool