Querying Your Applet’s Browser

Querying Your Applet’s Browser

Sometimes you write an applet that depends on a Microsoft Internet Explorer-specific extension which is not common to all browsers. How do you find out if the browser that’s running your applet supports the extension that you want to use?

Java provides a number of underlying classes that provide information about the system. For example, they can tell you what security manager is loaded, what OS your applet is running under, and which browser is running. You can then use this information to create an applet that’s sensitive to the browser under which it’s running.

First, get information about the system as a whole via the java.lang.System class method getProperty. The getProperty method allows the developer to get a wide variety of environment-specific information. It returns a string that represents the property that’s been requested. For example, to determine the OS that an applet is running under we could ask:

 String os = System.getProperty("");

Then use the information returned to build a browser-sensitive applet using the java.version and java.vendor properties.

See also  The Benefits of Patient Engagement Solutions for Healthcare Providers

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist