"Unable to launch MATLAB" in java

조회 수: 7 (최근 30일)
Donghun Kim
Donghun Kim 2018년 8월 31일
답변: Ziyu Hua 2022년 6월 26일
I want run matlab command in java by source code:
public class Test {
public static void main(String args[]) throws Exception {
MatlabEngine matEng = MatlabEngine.startMatlab(new String[] { "-useStartupFolderPref", "-nosplash", "-nodesktop", "-wait" });
matEng.eval("a = 10;", null, null);
matEng.eval("b = 20;", null, null);
StringWriter output = new StringWriter();
matEng.eval("a + b", output, null);
System.out.println(output.toString());
}
}
After I run this code, I should login in MATLAB because of Trial version. Login work successfuly. But, Matlab command dose not work with "com.matwork.engin.EngineException:Unable to launch MATLAB." message After successful login. How i can run matlab command line?
Perhaps, Matlab Java API isn't work in Trial version? Now I'm using Matlab 2018a trial version.

답변 (2개)

Zijie Li
Zijie Li 2019년 3월 21일
I have exactly same problem that you have and can't find the solution.
Have you solve the problem?

Ziyu Hua
Ziyu Hua 2022년 6월 26일
Hi Kim,
I also have the similar problem and the Java give an exception like:
"com.mathworks.engine.EngineException: Unable to launch MATLAB or connect a shared MATLAB session."
I resolve this problem By transform the Java 'System Enviroment Path' back to the default path of Matlab.
Which I did like this "Change the System Envioment Path" (I delete the MATLAB_JAVA), and solved the problems.
Which may be help.

카테고리

Help CenterFile Exchange에서 Call MATLAB from Java에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by