Set JavaScript Access to Java Classes
To find a way to detect the Java version the following script can be used:
var javaVersion = java.lang.System.getProperty("java.version");
System.log(javaVersion);
|
However, the use of Java classes, other than java.util.*, is limited, they must be explicitly enabled. You can find here a description how to set JavaScript access to Java classes in
Aria Automation 8.* and in
VCF Automation 9.*.
Hint: There was an error in the documentation that was corrected with release 8.11 on the 01.11.2023. The path was also specified here with
/vco/usr/lib/vco/yourFileName
. The
vco
path at the beginning was incorrect here.
-
If a shutter file is to be used, which allows an exact definition of the classes to be used, proceed as follows: Create a file with name
rhino-class-shutter-file
in the directory /data/vco/usr/lib/vco
.
A shutter file, to filter Java classes that are visible to scripts, can look like this:
com.*
io.*
java.*
javax.*
jdk.*
net.*
org.*
sun.*
|
-
Set system property
com.vmware.scripting.rhino-class-shutter-file
to /usr/lib/vco/rhino-class-shutter-file
.
Hint: This configuration is stored in the file vmo-managed.properties
in the location /data/vco/usr/lib/vco/app-server/conf
.

Hint: The Control Center is in future releases not more available. It is possible to set the system property via CLI or system properties.
vracli vro properties set --key com.vmware.scripting.rhino-class-shutter-file --value /usr/lib/vco/rhino-class-shutter-file
-
The program execution should now display the Java version.

-
If the following error occurs, after the restart of the Orchestration service and a new login into VCF Automation,
TypeError: Cannot call property getProperty in object [JavaPackage java.lang.System], it is not a function, it is "object"
the access to classes, outside of java.util.*, does not work.

-
This is exactly the same error message as in a simulation where the ClassShutter is set on the same way.
context.setClassShutter(new ClassShutter() {
public boolean visibleToScripts(String className) {
if (
className.startsWith("java.util")
) {
return true;
} else {
return false;
}
}
});
|

-
With Orchestrator 8.5.1 that Java version 11.0.12 is used and that it is an Zulu Azul distribution.
The Orchestrator 8.10.2 and 8.12.0 uses the Java version 11.0.16.1. The Orchestrator 8.14.0 uses the Java version 17.0.8.1, 8.16.2 uses Java 17.0.10, 8.18.0 uses Java 17.0.11 and all are BellSoft distributions.
-
The vendor information is available in the
java.vendor
system property.
Hint: It is also possible to set the system property com.vmware.scripting.javascript.allow-native-object
to true
.
var javaVendor = java.lang.System.getProperty("java.vendor");
System.log("Vendor: " + javaVendor);
var javaVersion = java.lang.System.getProperty("java.version");
System.log("Version: " + javaVersion);
var javaVmVersion = java.lang.System.getProperty("java.vm.version");
System.log("JVM Version: " + javaVmVersion);
var osName = java.lang.System.getProperty("os.name");
System.log("OS Name: " + osName);
var osVersion = java.lang.System.getProperty("os.version");
System.log("OS Version: " + osVersion);
var osArchitecture = java.lang.System.getProperty("os.arch");
System.log("OS Architecture: " + osArchitecture);
|