MATLAB Answers

Problems with using MATLAB Engine API for Java.

5 ビュー (過去 30 日間)
manan lalit
manan lalit 2017 年 3 月 2 日
コメント済み: manan lalit 2017 年 3 月 2 日
I wish to use the MATLAB Engine API in order to handle data and use MATLAB functions, in conjunction with a Java Front-End for the purpose of a graphical user interface.
To begin with, I tried playing with some sample code. As a first step, I added the external library (`Engine.jar') to my project in Eclipse:
Next, I wrote the following `test code' in order to check for effective compilation:
package application;
import com.mathworks.engine.*;
public class Main {
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");
Following is the hierarchy of files in my Java project:
This leads to the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: com/mathworks/mvm/MvmTerminatedException
at application.Main.main(
Caused by: java.lang.ClassNotFoundException: com.mathworks.mvm.MvmTerminatedException
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 1 more
Can anyone suggest what I need to do differently here? Thanks in advance.
  1 件のコメント
manan lalit
manan lalit 2017 年 3 月 2 日
Solved this problem. Realized that I had added the wrong external jar file.


回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by