Java Script runScript(final String script)

Here you can find the source of runScript(final String script)

Description

run Script

License

Open Source License

Declaration

public static void runScript(final String script) throws ScriptException 

Method Source Code


//package com.java2s;
/*-//from ww  w  .  j a v a2 s . c  o  m
 * #%L
 * This file is part of QuPath.
 * %%
 * Copyright (C) 2014 - 2016 The Queen's University of Belfast, Northern Ireland
 * Contact: IP Management (ipmanagement@qub.ac.uk)
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */

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

public class Main {
    public static void runScript(final String script) throws ScriptException {
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        ScriptEngine engine = scriptEngineManager.getEngineByName("JavaScript");
        engine.eval(script);
    }
}

Related

  1. getDynamicInput(String key)
  2. getScript(String name)
  3. getScriptCompileMsg(ScriptException ex)
  4. getSpParamOfWeiboLogin(String pwd, String servicetime, String nonce)
  5. removeScript(String name)
  6. toMap(ScriptObjectMirror som, Class type)
  7. toSci(BigDecimal bd, int sf)