Versions Compared

Key

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

...

 

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

...

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
 \}

...

  • 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>

...