Running Matlab script from Java (Intellij 2020.3 on Mac)
Hi there. I have been looking around all forums to understand how to run a Matlab script from Java, and have Intellij correctly compiling and running it. In specific, I am referring to this:
https://de.mathworks.com/help/matlab/matlab_external/setup-environment.html
Following their instructions, I have no problems in running my_java_code.java from mac terminal, however I cannot do the same in Intellij. This is the error I get: Exception in thread "main" java.lang.UnsatisfiedLinkError: no nativemvm in java.library.path: matlabroot/bin/maci64
I saw on other forums that users using Windows could solve it, but didn't find out any mac user who seems to have figured it out. Thanks a lot in advance for your help. Here below the screenshot of all my settings and error messages I am getting
- I'm using JDK15.0
- I HAVE SET





Please sign in to leave a comment.
I saw I had the running configurations badly set with "matlabroot" instead of the path in my computer. Changed but no different outcome. I am also trying to put the arguments I had in the command line within the specific field in configurations, but no difference. Thanks again
Hello,
I'd recommend you try to install Matlab plugin. (https://www.jetbrains.com/help/idea/managing-plugins.html), and create Matlab Run/Debug configuration:
Thanks for the answer. However I was not precise enough, I need to call a function coded in matlab from my java script. So I need java and matlab to interact, I want to pass arguments from java to a matlab function, and get back the output arguments. That's why I was working with the engine.jar library...
Got it, thanks. Try to specify -Djava.library.path in VM options instead of program arguments and check that you're using the correct path to bin/maci64. It seems like you need to replace matlabroot with Applications/MATLAB_R2020b.app/bin/maci64.
For example (Windows):
See also https://stackoverflow.com/questions/6092200/how-to-fix-an-unsatisfiedlinkerror-cant-find-dependent-libraries-in-a-jni-pro.