开发者

Integration of Jython and Python

I开发者_开发问答 have a Python application that is running as a console application. I did not like Python GUI libraries. That's why I want to use Java for GUI and python for application core. There are lots of details to read in the Jython documentation. I need a simple way to connect the GUI programmed in Java, and the core programmed in Python. What are your suggestions? Thanks in advance.


You could first try by taking an inventory of all the features/modules in the console based CPython application and ascertain whether or not they can be run under Jython. As Ignacio mentioned, not all third-party libraries will have been ported to Jython.

You would also have to be familiar with either AWT or Swing development to build the gui in Jython. However, it shouldn't be too difficult to decouple the gui code from the console based functionality.

One benefit is that the entire application can be bundled into a single JAR file along with Jython interpreter bootstrap code and the only dependency would be the Jython standalone JAR file and the application can be run with the user's installed JRE environment.

I don't know how many people do this, but I normally copy the Jython standalone JAR file to the JRE/lib/ext or JDK/jre/lib/ext directory depending on the environment.

This Jython Wiki entry has a great explanation of deployment options.


Jython is already mostly Python; only code that uses some core libraries and most third-party libraries will have to be modified, with corresponding Java packages or classes used for those instead.


There are several options like the jython already mentioned and of course the other is to use JEPP. See an example with jepp : java embedded python. I have to agree with the others, Jython is the easiest solution. For example :

PythonInterpreter interp = new PythonInterpreter();
interp.execfile("Filename.py");

That's all! Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜