Developer Information

This section includes the following topics:

Information for Web Page Authors 

Q: As a web page author, how do I use Java Plug-in Software?

A: To utilize all of the features and capabilities of Java 2 SDK, Standard Edition, web page authors must modify the page's HTML to specify the use of Sun's JRE via Java Plug-in. Sun is provides a specification—Using OBJECT, EMBED and APPLET Tags in Java Plug-in—to guide web page authors on how to make these changes. In addition, Sun provides the Java Plug-in HTML Converter, free of charge; it will automatically make the changes to the HTML of a selected web page or set of web pages.

Q: For Windows, the above specification mentions JRE releases that can be autodownloaded via .cab files. Where do I find a complete list of such JRE releases?

A: See Autodownload Files (Windows Only).

Q: How can I get the the Java Plug-in Software HTML Converter?

A: The Java Plug-in HTML Converter is bundled with the J2SE SDK. It is free.

Q: How do I run the HTML Converter?

A: See More About the HTML Converter.

Q: What capabilities do the supplementary templates provide with the Java Plug-in HTML Converter? 

A: The HTML Converter provides both a default template (default.tpl) and three supplementary templates. The supplementary templates allow web-page authors to more explicitly target browsers and platforms in their environment when modifying pages with the HTML Converter:

  1. default.tpl The default template used by the Java Plug-in HTML Converter. The converted page can be used in supported versions of Internet Explorer and Navigator on supported operating systems to invoke the Java Plug-in.
  2. extend.tpl The converted page can be used with any supported browser or platform. Java Plug-in will be invoked on all supported operating systems and browsers. If operating system or browser is not supported by Java Plug-in, then the browser's default Java runtime will be used.
  3. ieonly.tpl The converted page can be used to invoke Java Plug-in in supported versions of Internet Explorer on supported operating systems.
  4. nsonly.tpl The converted page can be used to invoke Java Plug-in in supported versions of Navigator on supported operating systems

Q: How do I specify a JAR file as part of an OBJECT or EMBED tag? 

A: You can specify one or more JAR files by defining an archive, cache_archive, or cache_archive_ex parameter in the OBJECT or EMBED tag.

The archive parameter with the OBJECT tag this looks like:

<PARAM NAME="archive" VALUE="demo.jar,fred.jar">

For more information on the cache_archive and cache_archive_ex parameters, see Applet Caching.

With the EMBED tag this looks like:

<EMBED ... archive="demo.jar,fred.jar" ... >

Q: Does Java Plug-in Software support multiple JAR files in the archive attribute in the APPLET tag? If so, why can't I get this to work?

A: The archive attribute is supported in both the EMBED and OBJECT tags. The most common mistake is to put the JAR files in the wrong order. For example, if you use the Swing set with Java Plug-in and specify archive="Myjar.jar,swing.jar,...", Java Plug-in will fail to load the applet because when Myjar.jar is loaded and Java Plug-in tries to initialize the applet, swing.jar is not yet loaded. The JAR files in the archive should be in the order of dependency; since Myjar.jar depends on other JARs, it should be put at the end of the list. The other common mistake is to put spaces or paths with the JAR file lists.

Information for Applet Developers 

Q: Do developers need to modify their applets in order to support Java Plug-in?

A: No. Any Java 2 SDK, Standard Edition, 100% Pure Java applets should run unmodified using the Java Plug-in.

Q: What is the applet lifecycle in Java Plug-in Software?

A: When an applet is encountered on an HTML page, the applet will be initialized and started. When the HTML page is closed, or the back button is pushed, the applet with be stopped and destroyed immediately.

When the same HTML page is encountered again, the applet will be initialized and started again.

Q: Does Java Plug-in Software support Drag and Drop between applets and the native environment? If so, why can't I get it to work?

A: Yes, Java Plug-in Software does support Drag and Drop. You must make sure to grant the applet the correct socket permissions using policytool to use this feature. Please see the SocketPermission class documentation for more information.

Q: How can I speed up applet download time?

A: There are several ways:

Q: How do I prevent the warning banner from covering my GUI state? 

A: You should use the getInsets() method to find the size of your frame's decorative border. This includes the warning banner. For example, if you create a Frame with size 100x100, you might find it has insets [top=42,left=5,bottom=5,right=6] giving you a drawable area of 89x53. You need to position your work within the drawable area.

If you need to create a drawable area of a particular size:

  1. create and show the Frame;
  2. use getInsets to find the insets' sizes;
  3. figure out the desired frame size by adding your desired size to the insets;
  4. then use frame.setSize() to set your frame to that size.

Q: Why does InetAddress.getLocalHost().getHostName() return localhost?

A: This is a deliberate security feature in the Java 2 platform. Untrusted applets will not be given the real host name. Trusted applets (such as signed applets) will be given the real host name.

Information for System Administrators

Q: I would like to change the Java Plug-in setting in thousands of machines through system management tools. What should I do?

A: Java Plug-in stores user specific settings under <user.home>/.java/properties<version>. Therefore, if administrators would like to change the Java Plug-in settting globally, they may use system managment tools to update the file in all machines.

Q: Does Java Plug-in Software replace Microsoft's or Netscape's Java runtime with Sun's JRE?

A: No. Java Plug-in Software does not replace the browser's underlying virtual machine if it has one. (Netscape 6 and later versions of Internet Explorere 6 do not have a Java virtual machine.) Rather, Java Plug-in Software simply enables web-page authors to specify that Sun's JRE be used instead of the default Java runtime.

Q: What happens on browsers other than IE or Navigator, or on non-supported platforms?

A: The default conversion template provided with the Java Plug-in HTML Converter is designed so that an applet will not be rendered in browsers other than Internet Explorer and Netscape Navigator on unsupported platforms. However, the Java Plug-in HTML Converter provides additional templates allowing web-page authors to specify that on non-supported platforms applets will be rendered using the original <APPLET> tag with the browser's default Java runtime.

Q: We are trying to deploy Java Plug-in Software within our intranet environment. The chapter called Using OBJECT, EMBED and APPLET Tags in Java Plug-in and other documents say we should set up an installation page within our intranet for Netscape users to install Java Plug-in. What does this page do and how should we set it up?

A: The purpose of this installation page is to act as an entry point for Netscape users to install Java Plug-in Software. If a user encounters an HTML page that requires Java Plug-in, the user will get redirected to this installation page according to the pluginspage attribute in the EMBED tag. At that point, the users should be able to download and install the correct version of Java Plug-in Software for their platform. Thus, the installation page should have links to download the Java Plug-in binary.

An simple example page would look like:

<TITLE>Java Plug-in Software Download Page</TITLE>
<P><A HREF="">
    Java Plug-in Software for Microsoft Windows</A>
<P><A HREF="">
        Java Plug-in Software for Solaris</A>
Depending on how your webserver is configured, you may want to consider using CGI scripting instead of FTP for the download. Contact your webmaster for more information.

Q: Why is the experience of downloading and installing Netscape Navigator different from Internet Explorer?

A: The releases of Netscape Navigator supported by Java Plug-in Software do not provide mechanisms that allow for the automatic download and installation of Java Plug-in, as in Internet Explorer. The first time Netscape Navigator comes across a web page that is enabled for Java Plug-in (the activated page), it redirects the user to another web page to download and install Java Plug-in Software on the user's system. The user must then return to the activated page to render the applet using Java Plug-in Software. From that point on, the browser automatically invokes Java Plug-in whenever it encounters an activated page.