Issue
Im am trying to compile this piece of code:
import com.mathworks.engine.*;
public class javaEvalFunc {
public static void main(String[] args) throws Exception {
MatlabEngine eng = MatlabEngine.startMatlab();
eng.evalAsync("[X, Y] = meshgrid(-2:0.2:2);");
eng.evalAsync("Z = X .* exp(-X.^2 - Y.^2);");
Object[] Z = eng.getVariable("Z");
eng.close();
}
}
I found it on this web page: https://www.mathworks.com/help/matlab/matlab_external/evaluate-matlab-expression-from-java.html
As you can see I need a reference to com.mathworks.engine.*;
This Page Mathworks Engine Info says that the .jar file that I need to Add is in this Path:
matlabroot/extern/engines/java/jar/engine.jar
But in my computer I just have a folder called phyton in this path
matlabroot/extern/engines
Where can Ifind the .jar file that I need ?
I am using Eclipse IDE by the way.
Solution
I had the same problem. You are looking in the right spot but your version of matlab doesn't support the Java Engine. You need to have Matlab R2016b or higher. It's not very clear in the documentation.
So i suggest that you download the newest version if your license permits that. Otherwise you can use a different interface to connect to matlab. matlabcontrol is often used for the same purpose but its quite old and poor documented.
Answered By - kobey
Answer Checked By - Terry (JavaFixing Volunteer)