Java 包装到 Perl/Python 代码 [英] Java Wrapper to Perl/Python code

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

问题描述

我必须在仅支持 Java 服务的服务器上部署一些 Web 服务,但其中一些将使用 perl 或 python 完成.我想知道是否可以开发一个 Java 包装器来调用用 perl 或 python 编写的特定代码.所以,我想拥有 Java 中的所有 Web 服务,但其中一些会使用其他语言调用一些代码.

I have to deploy some Web Services on a server that only supports the Java ones, but some of them will be done using perl or python. I want to know if is possible to develop a Java wrapper to call a specific code written in perl or python. So, I want to have all the Web Services in Java, but some of them will call some code using other languages.

提前致谢.问候,乌克兰

Thanks in advance. Regards, Ukrania

推荐答案

这在很大程度上取决于您的需求.如果 Jython 是 Python 代码的一个选项(它并不总是 100% 兼容),那么它可能是那里的最佳选择.否则,您将需要使用 Java 的 Process Builder 直接调用解释器并在其输出流中返回结果.这不会很快(但话说回来,相对于常规 Java 代码,Jython 也没有那么快),但它是一个非常灵活的解决方案.

This depends heavily upon your needs. If Jython is an option for the Python code (it isn't always 100% compatible), then it is probably the best option there. Otherwise, you will need to use Java's Process Builder to call the interpretters directly and return the results on their output stream. This will not be fast (but then again, Jython isn't that fast either, relative to regular Java code), but it is an extremely flexible solution.

这篇关于Java 包装到 Perl/Python 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆