Message5816
public class JythonTest
{
public static void main(String anArguments[]) throws Exception
{
jythonDirect();
jythonJSR223();
}
private static void jythonDirect()
{
PythonInterpreter myInterpreter = new PythonInterpreter();
myInterpreter.exec(
"from java.lang import String\n" +
"myString = String('Test')\n" +
"myResult = myString.substring(1,2)");
System.out.println("Direct Jython result: " +
myInterpreter.get("myResult"));
}
private static void jythonJSR223()
throws ScriptException
{
ScriptEngine myEngine = new ScriptEngineManager().
getEngineByName("jython");
if (myEngine == null)
{
throw new RuntimeException("Script engine not found!");
}
myEngine.eval(
"from java.lang import String\n" +
"myString = String('Test')\n" +
"myResult = myString.substring(1,2)");
System.out.println("JSR223 result: " + myEngine.get("myResult"));
}
} |
|
Date |
User |
Action |
Args |
2010-06-16 15:20:42 | frbo | set | messageid: <1276701642.46.0.790498042258.issue1621@psf.upfronthosting.co.za> |
2010-06-16 15:20:42 | frbo | set | recipients:
+ frbo |
2010-06-16 15:20:42 | frbo | link | issue1621 messages |
2010-06-16 15:20:41 | frbo | create | |
|