I have a Java program which gets data from a database in the form of a list of objects and an object just has some primitive types associated to it like strings and ints.
Now I need to pass the data from Java to a Python program to do some calculations and then return the calculated output to the Java program.
My Python program has the following imports
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
import numpy as np
import scipy.misc as sp
from scipy.optimize import minimize
from scipy.stats import poisson
Does anyone have any ideas for how I could achieve this? I looked at Jython but saw that it isn't compatible with NumPy and others but there is a compatibility layer available called JyNI however I can't find many examples to getting a working solution.
EDIT: From my research, there doesn't seem to be a suitable library which will handle communication between Java and Python but would it be possible to the Java program to start a Python script which looks for say a JSON file containing the data it needs for processing and then prints an output that Java can pick up?
I am of the opinion, that you stand to have several choices; my personal favourites are as follows:
There are probably many other little workarounds and solutions that people have come up with in the past (native embeddings, higher level control, etc.), but these are my best offers to you, as they cause the least trouble (as far as I am aware). I hope this answers your question, and best of luck to you.
A short list of maths libraries useful in Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With