Guest User

Untitled

a guest
Jan 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package de.tdlabs.training.scripting;
  2.  
  3. import javax.script.Compilable;
  4. import javax.script.ScriptEngine;
  5. import javax.script.ScriptEngineManager;
  6. import javax.script.ScriptException;
  7.  
  8. public class CheckJavaScriptSyntaxExample {
  9.  
  10. public static void main(String[] args){
  11.  
  12. ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
  13. Compilable compiler = (Compilable) engine;
  14.  
  15. try {
  16. compiler.compile("fu_nction(a,b){ return a+b;}");
  17. } catch (ScriptException e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. }
Add Comment
Please, Sign In to add comment