Search notes:

Java class javax.script.ScriptEngine - eval

public class eval {

  public static void main(String[] argv) {

    javax.script.ScriptEngine se = new javax.script.ScriptEngineManager().getEngineByName("javascript");

    try {
      Object ret = se.eval(
       "  a = 21; " +
       "  b =  2; " +
       "  a*b "
      );
      System.out.println(ret.toString());

      ret = se.eval(new java.io.FileReader("division.js"));
      System.out.println(ret.toString());

    }
    catch (javax.script.ScriptException e) {
      System.out.println(e.toString());
    }
    catch (java.io.IOException e) {
      System.out.println(e.toString());
    }

  }

}
Github repository JavaClasses, path: /javax/script/ScriptEngine/eval.java
The evaluated file is:
// Note: The variables a and b are defined
// in the hardcoded evaluated script in eval.java
a/b
Github repository JavaClasses, path: /javax/script/ScriptEngine/division.js

See also

Java classes

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199940, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Java/classes/javax/script/ScriptEngine/eval(72): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78