LINUX.ORG.RU

История изменений

Исправление stevejobs, (текущая версия) :

eval ()
Java
химия

JDK.isIncluded(«JavaScript Engine Nashorn») == TRUE

next_time.addExample("

package sample1;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class Hello {

  public static void main(String... args) throws Throwable {
    ScriptEngineManager engineManager = 
new ScriptEngineManager();
    ScriptEngine engine = 
engineManager.getEngineByName("nashorn");
    engine.eval("function sum(a, b) { return a + b; }");
    System.out.println(engine.eval("sum(1, 2);"));
  }
}
");

next_time.isOK() ?

Исходная версия stevejobs, :

JDK.isIncluded(«JavaScript Engine Nashorn») == TRUE

next_time.addExample("

package sample1;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class Hello {

  public static void main(String... args) throws Throwable {
    ScriptEngineManager engineManager = 
new ScriptEngineManager();
    ScriptEngine engine = 
engineManager.getEngineByName("nashorn");
    engine.eval("function sum(a, b) { return a + b; }");
    System.out.println(engine.eval("sum(1, 2);"));
  }
}
");

next_time.isOK() ?