Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Typos

...

The JobScheduler supports different scripting engines:

...

  • The SpiderMonkey engine is only available for 32 bit JobScheduler. It is selected by <script language="javascript"> and <script language"spidermonkey">
  • The Rhino engine is available for 32 bit and 64 bit. It is selected by <script language="javax.script:rhino">, <script language="javax.script:JavaScript"> and <script language="javax.script:ECMAscript"/> for a JRE up to 1.7
  • The Nashorn engine is available for 32 bit and 64 bit. It is selected by <script language="javax.script:JavaScript"> and <script language="javax.script:ECMAscript"/> for a JRE starting from 1.8
  • The "Rhino (with Beans)" / "Nashorn (with Beans)" engine is available for 32 bit and 64 bit. It is selected by <script language"java:javascript">

Language

Used Engine on 32 bit Bit JobScheduler

Used Engine on 64 bit Bit JobScheduler

Available in
JobScheduler Release

spidermonkey

SpiderMonkey

All releases, only 32Bit32 bit

javascript

SpiderMonkey

All releases, only 32Bit32 bit

javax.script:rhino

Rhino (up to JRE 1.7 only)

Rhino (up to JRE 1.7 only)

Starting from 1.65
javax.script:JavaScript

up to JRE 1.7: Rhino
starting from JRE 1.8: Nashorn

up to JRE 1.7: Rhino

starting from JRE 1.8: Nashorn
Starting from 1.65
javax.script:ECMAscript

up to JRE 1.7: Rhino
starting from JRE 1.8: Nashorn

up to JRE 1.7: Rhino

starting from JRE 1.8: Nashorn
Starting from 1.65

java:javascript

JRE 1.7: Rhino (with Java beans layer)
JRE 1.8: Nashorn (with Java beans layer)

JRE 1.7: Rhino (with Java beans layer)
JRE 1.8: Nashorn (with Java beans layer)

Starting from 1.65

If you want to migrate a Javascript for SpiderMonkey to a 64 bit JobScheduler then in most cases you just have to modify the language attribute to <script language="java:javascript">. This works within limits.

...

Code Block
languagejs
titleExample: compatible solution
 var file = Packages.java.io.File(files[i]);
 file["delete"]();				// because delete is reserved in javascript

Getting Java Objects

The following ECMA script construction can be used to instantiate Java objects using new Packages.myPacket.myClass();

Code Block
languagejs
titleExample:Getting Java Objects
function myFunction(){
    
    var params;
    
    var debugParameter = function(paramName) {
        try{
            spooler_log.debug1(".. mail parameter ["+paramName+"]: "+params.value(paramName));
        } catch (e){} //No error handling
    }
    
    try{
        var myVariable = spooler_log.mail();
        this.myObject = new Packages.myPacket.myClass();
        ....
    } catch(e){
        throw "Error initializing myObject: "+e;
    }
    ....
}

 

Note that import myPacket.myClass(); will cause an initialization error message when used in ECMA script.

For example, the following error would be typical for import sos.net.SOSMail;

Code Block
languagejs
titleExample: Getting Java Objects
[ERROR]  COM-80020009  Ausnahmefehler aufgetreten. [step] [] [Z-JAVA-105  Java exception java.lang.RuntimeException: javax.script.ScriptException: sun.org.mozilla.javascript.internal.JavaScriptException: Error initializing sosMail: TypeError: Cannot find function set_queue_dir in object sos.net.SOSMail@2403f3b1. (<Unknown source>#39) in <Unknown source> at line number 39 - caused by - javax.script.ScriptException: sun.org.mozilla.javascript.internal.JavaScriptException: Error initializing sosMail: TypeError: Cannot find function set_queue_dir in object sos...], method=call

For more information, see:

See also

...