Finally I have a proper usecase for using Jython as an integrated scripting engine in a Java-project. The opportunity came in a current project, where we do collaboration with third party who developes a certain calculation model which will be shared intellectual property between us and also released to the general public. Usage on Jython allows us to model the calculation model as python code, create it easily readable and runnable code on almost any and every desktop computer – and run the same code on our backend. Which is nice.
Based on the documentation and quick tests, integrating Jython is a snap and using JSR 233 or native interface are almost similar, though I’d prefer JSR 233 scripting api.
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
TestObject foo = new TestObject();
foo.setName("Name of the object");
engine.eval("foo.name = Changed name");
TestObject grab = (TestObject) engine.get("foo");
Works like a charm.