/* * * * Copyright (C) 2005-2008 Yves Zoundi * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * */package javaapplication10;import bsh.Interpreter;import groovy.lang.Binding;import groovy.lang.GroovyShell;import org.jruby.Ruby;import org.jruby.runtime.builtin.IRubyObject;import org.python.core.PyObject;import org.python.util.PythonInterpreter;/** * * @author Yves Zoundi <yveszoundi at users dot sf dot net> */public class Main { /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { // jython sample PythonInterpreter pi = new PythonInterpreter(); PyObject pyObject = pi.eval("1 + 2"); System.out.println("Python object: " + pyObject); // jruby sample Ruby irb = org.jruby.Ruby.getDefaultInstance(); IRubyObject rubyObject = irb.evalScript("1 + 2"); System.out.println("Ruby object: " + rubyObject); // groovy sample Binding binding = new Binding(); GroovyShell shell = new GroovyShell(binding); Object groovyObject = shell.evaluate(" 1 + 2"); System.out.println("Groovy object: " + groovyObject); // beanshell sample Interpreter i = new Interpreter(); // Construct an interpreter Object bshObject = i.eval("1 + 2"); System.out.println("Beanshell object: " + bshObject); }}