Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Starting Situation

...

Java 1.8 comes with a different JavaScript engine ("Nashorn") to that included in Java7 Java 1.7 ("Rhino"). As JobScheduler can use the JavaScript engine provided with Java for shell scripts, it is important that users wishing to use Java 1.8 in with future JobScheduler versions releases ensure that their scripts are capable of being executed with the Nashorn engine.

...

...

  •  Instead of the importClass statement you can use the class JavaImporter

Differences in Practice

Example

...

for class import

  • Rhino only:
Code Block
languagejs
titleExample: class import with Rhino
 importClass(java.io.File);
 importClass(java.nio.charset.Charset);
  • Rhino and Nashorn:
Code Block
languagejs
titleExample: class import with Rhino and Nashorn
 var imports = new JavaImporter(
     java.io.File,
     java.nio.charset.Charset
 );

...

Common Usage Example

Code Block
languagejs
titleExample: common usage with Rhino and Nashorn
 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
languagejs
titleExample: multi engine script
 <script language="javax.script:javascriptJavaScript">
     <![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

...

  • recommend that users specify that the default JavaScript engine for the Java

...

  • version is used

...

  • , i.e. "javax.script:

...

  • JavaScript" instead of "javax.script:rhino".
  • This

...

  • will ensure that the changeover of the JavaScript engine will occur at the same time as the changeover to Java 1.8.
  • Please note that

...

  • at the time of writing it is not yet decided when JobScheduler will become Java 1.8 capable but this is likely to occur towards the end of 2014. Oracle have announced that they will stop updating Java 7 after April 2015.

See also