Running MATLAB function from Java

The trick is to use the MatlabControl class http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html. It's very easy to use and you can do exactly what you're trying to do (and more).


matlabcontrol is based on the same underlying MATLAB library used by MatlabControl mentioned by Jeff, but is more up to date, reliable, and documented. To get started, take a look at the walkthrough.


In Matlab R2016b, MathWorks added MATLAB Engine API for Java which allows to execute MATLAB code from Java.


JAMAL is an open source, Java RMI-based (Java Remote Method Invocation API) library that suits your needs