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 a description
how to set JavaScript access to Java classes here.
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.
-
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 necessary to set the system property via CLI.
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;
}
}
});
|

-
Another way to get the Java version is to set the system property
property com.vmware.js.allow-local-process
to true.

Hint: The Control Center is in future releases not more available. It is necessary to set the system property via CLI.
vracli vro properties set --key com.vmware.js.allow-local-process --value true
Now it is possible to get the Java version with the following command sequence:
var com = new Command("jdk/bin/java --version");
com.execute(true);
System.log(com.output);
|

Hint: The Command object is not available from Aria Automation release 8.17.0 until 8.18.0.
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.
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);
|