在java和python之间传递数据 [英] passing data between java and python

查看:641
本文介绍了在java和python之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的问题是noob,抱歉我使用pgsql 8.4运行Django 1.2,我需要在从用户获取输入后运行Java程序,进行一些计算并将结果返回给用户。



我可以知道在Java和Python Django之间传递数据的最佳方法是什么?我听说过Jython,但是根据Django文档,它需要扩展jython-Django,但目前它不支持django 1.2.x.我应该使用stdout传递数据吗?



感谢人们听到我的意见。

解决方案

使用子流程,并以简单的子流程运行Java程序。这非常非常简单和合理的快速。



如果您需要做更多可扩展的内容,那么您应该考虑创建一个 glassfish 服务器与您的Java代码,所以您的Python可以使Web服务请求到Java。这是更可扩展的,但也更多的工作。


Apologies if my question is noob. I'm running Django 1.2 with pgsql 8.4 and I'm required to run a Java program after getting the inputs from the user, does some calculations and return the results back to the user.

May I know what is the best way to pass data between the Java and Python Django, such that the above scenario are taken care of? I heard of Jython, but according to the Django docs, it requires the extension jython-Django, but currently it doesn't support django 1.2.x. Should I pass the data using stdout?

thanks people for hearing me out.

解决方案

Use subprocess and run the Java program as a simple subprocess. It's very, very simple and reasonably fast.

If you need to do something more scalable, you should look at creating a glassfish server with your Java code so your Python can make web services requests to the Java. This is more scalable, but also more work.

这篇关于在java和python之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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