...
The JobScheduler supports different scripting engines:
- SpiderMonkey (http://www.mozilla.org/js/) which is included in all 32 Bit JobScheduler releases
- Rhino (http://www.mozilla.org/rhino/) which is part of the Java Run Time Environment (JRE) for versions up to JRE 1.7
- Nashorn (https://blogs.oracle.com/nashorn/) which is part of the Java Run Time Environment for versions starting from JRE 1.8
...
- 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 |
---|---|---|---|
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 | 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 | 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.7: Rhino (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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
[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:
- https://helpx.adobe.com/experience-manager/kb/JavaFromEsp.html
- Importing Java Classes to ECMAScript with the import Statement
See also
- What Java scripting languages are supported?
- How to change over to Java 1.8 - the new Nashorn JavaScript engine
...