Nothing like writing a "hello world" program with new Java APIs! A simple Java program to use JSR 223 (javax.script) API with Mustang is as follows:
//import package
import javax.script.*;
public class Main {
public static void main(String[] args) {
try {
// create a script engine manager
ScriptEngineManager manager = new ScriptEngineManager();
// create script engine for JavaScript
ScriptEngine jsengine = manager.getEngineByName("js");
// evaluate JavaScript code from String
jsengine.eval("print('hello world')");
} catch (ScriptException se) {
// Handle script exception here..
// FIXME: do a better job here!
se.printStackTrace();
}
}
}
Posted by Alex Goncalves on August 08, 2005 at 11:27 PM IST #
Posted by Roman Strobl on August 09, 2005 at 01:59 AM IST #
Roumen: nice blog entry! Thanks.. I saw it after I wrote this entry. I am planning to write more on scripting [if I can overcome my laziness :-)]
Posted by Sundararajan on August 09, 2005 at 01:52 PM IST #
//import package import javax.script.*; public class Main { public static void main(String[] args) throws Throwable { // create a script engine manager ScriptEngineManager manager = new ScriptEngineManager(); // create script engine for JavaScript ScriptEngine jsengine = manager.getEngineByName("js"); // evaluate JavaScript code from String jsengine.eval("print('hello world')"); } }Posted by David Spencer on August 09, 2005 at 09:21 PM IST #
import javax.script.*; public class Main { public static void main(String[] args) throws Throwable { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine jsengine = manager.getEngineByName("js"); jsengine.eval("print('hello world')"); } }Posted by Roman Strobl on August 09, 2005 at 11:48 PM IST #
public class Main { public static void main(String[] args) throws Throwable { new javax.script.ScriptEngineManager().getEngineByName("js").eval("print('hello world')"); } }Posted by Pajosh on August 10, 2005 at 01:44 AM IST #
<code> jrunscript -e "print('hello world')" </code>Posted by Sundararajan on August 10, 2005 at 12:22 PM IST #
Posted by Mohan Radhakrishnan on August 10, 2005 at 06:15 PM IST #
Posted by Sundararajan on August 11, 2005 at 09:36 AM IST #
Posted by 221.134.212.136 on September 16, 2005 at 07:14 AM IST #
Posted by joe on April 22, 2006 at 06:58 AM IST #
Posted by Teckie Life at Southwest MSU... on December 15, 2006 at 10:10 AM IST #