...
- Oracle Nashorn: A Next-Generation JavaScript Engine for the JVM.
We recommend JobScheduler users running JavaScript scripts use this article to update their scripts.
One of the most important changes is likely to be that Nashorn does not support theimportClass
statement.
Instead of the importClass
statement you can use the class JavaImporter
Example:
- Rhino only:
Code Block |
---|
importClass(java.io.File);
importClass(java.nio.charset.Charset);
|
- Rhino and Nashorn
Code Block |
---|
var imports = new JavaImporter(
java.io.File,
java.nio.charset.Charset
);
|
usage
Code Block |
---|
with (imports) \{
// usage of File
// usage of Charset
\}
|
Multi Engine script
- The following script with language
javax.script:javascript
uses Rhino engine on Java 1.7 and Nashorn engine on Java 1.8 and works on both engines:
Code Block |
---|
<script language="javax.script:javascript">
<![CDATA[
var imports = new JavaImporter(
java.io.File,
java.nio.charset.Charset
);
function spooler_process() \{
with (imports) \{
// usage of File
// usage of Charset
\}
// also possible:
// usage of java.lang.Thread
return true;
\}
]]>
</script>
|
Job Script Changes
To make the changeover as smooth as possible, we also recommend that users specify that the default JavaScript engine for the Java Version is used:
i.e. "javax.script:ECMAscript
" instead of javax.script:rhino
.
This wil ensure that the changeover of the JavaScript engine will occur at the same time as the changeover to Java 8.
...