Developer tutorial - How to detect Java
detect flash
download BrowserHawk detect disabled cookies BrowserHawk pricing and ordering detect connection speed Contact information for cyScape
detect Acrobat plugin
Information on browser detect, browser compatibility, browser testing, web site usability

Why detect Java?   [See your Java test results]

One of the most challenging aspects of deploying Java applets is guaranteeing that your visitor's browser has Java installed, enabled, and of a particular version and vendor that are known to work with your applet.

BrowserHawk makes this process easy by enabling you to detect, before sending your applet to the client, what the client's capabilities and settings are.

For example, if the visitor doesn't have Java installed, you can prompt them to install it. If they have Java installed but disabled, you can prompt them to enable it. And if their Java version does not meet your requirements, you can let them know this as well.

Of course, the main idea here is that you can proactively determine whether the visitor meets your requirements to properly run your applet. And if not, you can guide them through corrective action via the web site. This approach helps ensure that your visitors have a pleasant and productive experience on your web site.

Without taking this proactive approach, you could easily leave users frustrated and alienated, without intending to, as well as tie up your help desk resources for assistance that could be otherwise automated.

 
How to best use BrowserHawk to detect Java

Java detection isn't as easy as a simple on/off switch because of the various settings and variables involved. This article, therefore, will walk you through the process and explain how to make the most of BrowserHawk when detecting your visitor's Java capabilities within their browser.

For your convenience, we have included samples for classic ASP, ASP.NET (C# and VB.NET), JSP and CFMX that test the various properties involved in detecting Java, and based on the returned values, summarizes the client's Java capabilities. You should feel free to use these samples as the basis for your own application or just follow the recipe below that's implemented by the samples, as follows:

  1. First, collect all the standard browser properties and the following extended properties: JavaScriptEnabled, JavaEnabled, Plugin_JavaVer, JavaVersion, JavaVendor, and MSJVMBuild
  2. Verify that the client browser is Netscape, Mozilla, Firefox, IE, Opera, or Safari. These are the only clients supported for extended property detection. If the browser is some other variety, Java detection is not supported.
  3. Confirm that JavaScript is enabled by looking at the JavaScriptEnabled property. For clients with JavaScript disabled no extended property values are available.
  4. Further verify that the client browser version supports all of the extended properties listed above. This means the browser must be IE Windows 3.0+ (except exactly 4.00), Mozilla, Firefox, Safari 1.2+, or Netscape 4.0+.
  5. Check if JavaVersion = -3. This means that we know definitively that no Java is available, without any further analysis necessary.
  6. Check if JavaEnabled is false while the Plugin version seems legitimate (Plugin_JavaVer is non-null, non-empty). This indicates the Java Plugin is installed but not enabled.
  7. Check if JavaEnabled is false while the Microsoft JVM Build looks legitimate (MSJVMBuild is non-null, non-empty). This indicates the Microsoft JVM is installed but not enabled.
  8. Check if JavaEnabled is false while neither the Plugin nor Microsoft JVM look legitimate. This indicates there's probably no Java installed.
  9. Check if JavaEnabled is true while JavaVersion is the error code -1. This indicates the client has a very old JVM which can't be accessed from JavaScript. Or this could also mean that the JVMDetector.class file cannot be found - see above.
  10. Check if JavaEnabled is true while JavaVersion is the error code -2 and also Plugin_JavaVer appears legitimate. This indicates the Java Plugin is installed but the scripting of applets is explicitly disabled. Or this could also mean that the JVMDetector.class file cannot be found - see above.
  11. Check if JavaEnabled is true while JavaVersion is the error code -2 and also MSJVMBuild appears legitimate. This indicates the Microsoft JVM is installed but scripting of applets is explicitly disabled. Or this could also mean that the JVMDetector.class file cannot be found - see above.
  12. Check if JavaEnabled is true, JavaVersion is -2, and both Plugin_JavaVer and MSJVMBuild are not legitimate (both null or empty). This indicates no Java is installed. Or this could also mean that the JVMDetector.class file cannot be found - see above.
  13. Check if JavaVersion has a legitimate value. This indicates that Java is ready to run applets and the version and vendor can be found via JavaVersion and JavaVendor.

    It's also possible in this case to look at the Plugin_JavaVer to see if another Java version is available to run applets. If the Plugin_JavaVer and JavaVersion versions have different major versions, this is the case. If the Java Plugin is a higher version, you may want to prompt the client to turn on the Plugin.
Please note it works best to test the properties in the sequence listed above. If you were to jump directly to test #6 for example you'd falsely conclude there's no Java installed when in fact perhaps JavaScript's simply disabled.

You may also want to add into your test matrix a requirement that the client be using a particular browser version or operating system. You can obtain this information from other BrowserHawk properties such as Browser and Platform.

 
Download samples for detecting Java

Download the source code (provided in Classic ASP, ASP.NET (C# and VB.NET), JSP, and CFMX) of samples that demonstrate Java detection with BrowserHawk. These samples provide the framework for programmatically interpreting the Java detection test results based on the criteria discussed in this article. This will come in handy when implementing Java detection in your web applications.

NOTE: In order for BrowserHawk to detect Java details you must place the JVMDetector.class file into the same web directory where your script that detects Java settings resides. Or, you can place it in a different web directory as long as you use the JVMCodeBase property to tell BrowserHawk what the path is to the file. This file can be found within your installed BrowserHawk files on your system. Java detection requires BrowserHawk Enterprise Edition.

 
Your Java Settings as detected by BrowserHawk

The following are the results from the BrowserHawk Java detection on your browser, as demonstrated in this article:

Property
Value
JavaEnabled
False
Plugin_JavaVer
JavaVersion
JavaVendor
MSJVMBuild
Conclusion from test results:
JavaEnabled returned false and Plugin_JavaVer/MSJVMBuild detection returned no legitimate value.
This indicates you probably have no Java installed.

Back to top of article


 
[Back to top] 
IBASA
detect browser settings, maximize web site ROI, web site usability
Home | Products| Company | Support | Developer | Pricing & Ordering | Downloads | Search
 
cyScape, BrowserHawk, BrowserHawk To-Go, BrowserHawk IQ and CountryHawk are trademarks or registered
trademarks of cyScape, Inc. Copyright © 2020 cyScape, Inc. All Rights Reserved. web analytics
ASP, ASP.NET, ColdFusion MX, CFMX, JSP, PHP
detect screen size, detect Java, IBASA, Intelligent Browser and System Analysis