Java Python集成

扫码查看
本文介绍了Java Python集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要与第三方库集成的Java应用程序。该库是用Python编写的,我对此没有任何发言权。我正在试图找出与它集成的最佳方式。我正在尝试JEPP(Java嵌入式Python) - 以前有人用过吗?我的另一个想法是使用JNI与Python的C绑定进行通信。

I have a Java app that needs to integrate with a 3rd party library. The library is written in Python, and I don't have any say over that. I'm trying to figure out the best way to integrate with it. I'm trying out JEPP (Java Embedded Python) - has anyone used that before? My other thought is to use JNI to communicate with the C bindings for Python.

任何关于最佳方法的想法都将受到赞赏。谢谢。

Any thoughts on the best way to do this would be appreciated. Thanks.

推荐答案

为什么不使用的?我可以立即想到的唯一缺点是你的库是否使用CPython原生扩展。

Why not use Jython? The only downside I can immediately think of is if your library uses CPython native extensions.

编辑:如果你现在可以使用Jython 但是你认为对于更高版本的库可能有问题,我建议您尝试将库与应用程序隔离(例如某种适配器接口)。选择目前最简单的东西,然后考虑JNI / CPython /等,如果需要的话。除非你真的需要,否则去(痛苦的)JNI路线几乎无法获得。

If you can use Jython now but think you may have problems with a later version of the library, I suggest you try to isolate the library from your app (e.g. some sort of adapter interface). Go with the simplest thing that works for the moment, then consider JNI/CPython/etc if and when you ever need to. There's little to be gained by going the (painful) JNI route unless you really have to.

这篇关于Java Python集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 19:20
查看更多