goh goh - 1 year ago 144
Java Question

passing data between java and python

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download