Commits

Shashank Bharadwaj committed 4aa158d

adding blurb about JSR 223

Comments (0)

Files changed (1)

 java.lang.Object                  String
 org.python.core.PyObject          unchanged
 Foo                               JavaInstance
+
+Using Jython code from Java
+===========================
+
+* Using Java scripting API provided via JSR-223
+* Object factories
+
+Using the Scripting API
+=======================
+
+    import javax.script.ScriptEngine;
+    import javax.script.ScriptEngineManager;
+
+    public class Main {
+
+      public static void main(String[] args) {
+        ScriptEngine engine = new ScriptEngineManager().
+	    getEngineByName("python");
+
+        engine.eval("answer = 12 + 30");
+        Object x = engine.get("x");
+    	System.out.println("x: " + x);
+      }
+    }
+
+* Add jython-engine.jar and jython.jar to class path
+
+Scripting API is:
+=================
+
+* Easy to use
+* Developed as part of JSR-223
+* Ideal for running scripts in Python from Java, get intermediate results
+* But it's slow and unoptimized.
+
+Object Factories
+================
+