JVMCodeBase Property

 

Type: String

 

This optional property is used to specify the virtual directory that contains the cyScape supplied JVMDetector.jar file used when testing the JavaVersion or JavaVendor property.

 

If you kept the default option of checking for Java version / vendor during the installation, BrowserHawk prompted you during the install for the location of where this .jar file should be stored.

 

By default BrowserHawk assumes that this .jar file resides in the same web directory as the script you are checking the JavaVersion or JavaVendor property from. For example, assume you are checking JavaVersion from www.mysite.com/mainsite/login.asp. In this case BrowserHawk expects to find the JVMDetector.jar file in the same directory as the login.asp page. In this scenario where the .jar file exists in the same directory as the script, there is no need to set the JVMCodeBase property.

 

However, assume you need to check the JavaVersion from both www.mysite.com/mainsite/login.asp and www.mysite.com/usa/check.asp. In this case, without setting the JVMCodeBase property, you would need to place a copy of the .jar file in both the directory where login.asp resides as well as in the directory where check.asp resides.

 

This is where the JVMCodeBase property comes in. In this scenario you could set the JVMCodeBase to point to one specific directory. This causes BrowserHawk to set the CODEBASE parameter when writing out the <APPLET> tag used in the test to the location specified in this property. This enables you to keep just one instance of the .jar file on your server and makes for cleaner maintenance in the future.

 

Note: The location pointed to by the JVMCodeBase directory must be a relative web directory that is accessible to users through their web browser. For example, "./sharedfiles" or "/mysite/jars" and not "c:\inetpub\wwwroot\jars", etc.

 

Example 1:

This example assumes you only need to check for JavaVersion from www.mysite.com/mainsite/login.asp. In this case make sure the JVMDetector.jar file is located in the same directory where login.asp resides. Note in this example there is no use of the JVMCodeBase property since it is not needed in this scenario.

<% set bhObj = Server.CreateObject("cyScape.browserObj")

bhObj.SetExtProperties "JavaVersion"

bhObj.GetExtPropertiesEx %>

<html> JVM version is: <% = bhObj.JavaVersion %>

 

Example 2:

This example assumes you need to check for JavaVersion from both www.mysite.com/mainsite/login.asp and www.mysite.com/usa/check.asp. In this case we want to avoid multiple copies of the JVMDetector.jar file. Instead of placing a copy of this file in the directories where the login.asp and check.asp scripts are located, we place it our sharedfiles directory. Then we set the JVMCodeBase property to point at this directory.

<% set bhObj = Server.CreateObject("cyScape.browserObj")

bhObj.SetExtProperties "JavaVersion"

bhObj.JVMCodeBase = "/sharedfiles" 'note this must come before call to GetExtPropertiesEx

bhObj.GetExtPropertiesEx %>

<html> JVM version is: <% = bhObj.JavaVersion %>

 

Remember, if your web scripts execute from the same directory where the .jar file is stored, you do not need to set this property. Otherwise you should set it to point to one central location where all scripts can use it.

 

Tip: If you receive a return value of –2 for JavaVersion and/or JavaVendor when testing the most likely reason is that the JVMDetector.jar file does not reside in the directory where the script is executing in, or is not located in the relative directory specified by the JVMCodeBase property.

 

See Also:

JavaVersion Property

JavaVendor Property

GetExtPropertiesEx Method

SetExtProperties Method