Package

Source Code of TestScripting

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.*;


/*
This Tutorial is a tutorial for more advanced developers.
If you are currently just playing around with the Irrlicht
engine, please look at other examples first.

This tutorials shows how to use a ajavascript file for creating
and running an irrlicht universe.
*/

/**
* This program loads and executes the JavaScript program
*
* @author Sergey Nechaev (snechaev@javazing.com)
*/

public class TestScripting
{

  private static final String SCRIPT_ENGINE_NAME = "js";
  private static final String SCRIPT_FILE_NAME = "script/js.js";

  private ScriptEngine jsEngine;
  private ScriptEngineManager mgr;


  static
  {
    System.loadLibrary("irrlicht_wrap");
  }

  public static void main(String[] args) throws Exception
  {
    new TestScripting();
  }

  public TestScripting() throws Exception
  {
    mgr = new ScriptEngineManager();
    jsEngine = mgr.getEngineByExtension(SCRIPT_ENGINE_NAME);

    // InputStream is = this.getClass().getResourceAsStream("js.js");
    File file = new File(SCRIPT_FILE_NAME);
    InputStream is = new BufferedInputStream(new FileInputStream(file));
    Reader reader = new InputStreamReader(is);

    jsEngine.eval(reader);
  }
}

TOP

Related Classes of TestScripting

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.