MATLAB Answers

Run executable file created by Matlab Compiler in Java: error of MCR

조회 수: 7(최근 30일)
I'm trying to call my executable file with a Java program. Here are the steps I followed:
  1. Compile the package including MCRinstaller.exe on my machine
  2. Double click on the package on the host machine: everything is properly installed
  3. The program can be run on the host machine without problem
  4. ...
  5. Call the .exe file from my Java program:
Process exec = Runtime.getRuntime().exe
The (same) program is not running:
Could you help me to understand why if I launch the exe file directly it works and when I launch it from Java there is an error?
Best regards.

채택된 답변

Sébastien MAILFERT
Sébastien MAILFERT 2014년 6월 4일
편집: Sébastien MAILFERT 2014년 6월 4일
Thanks titus for your answer. This should be the answer. You're right, the missing .dll is located there:
C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v715\runtime\win32
I added the following line in my Java code:
java.lang.System.load("C:\\Program Files (x86)\\MATLAB\\MATLAB Compiler Runtime\\v715\\runtime\\win32\\mclmcrrt7_15.dll");
Now, the Java program générâtes an error because the .dll file is a 32bits dll and not a 64bits dll:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v715\runtime\win32\mclmcrrt7_15.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
It's right, the host machine has a 64bits OS. It seems that when I run the executable outside Java, the dll which is called is not the same as when I run it with Java, rigth?
Bests. Sébastien
  댓글 수: 5
Sébastien MAILFERT
Sébastien MAILFERT 2014년 6월 6일
Dear Titus, this solved my problem! I can know run my executable file with Java without Matlab :-) Thanks for your precious hep. Bests Sébastien

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Titus Edelhofer
Titus Edelhofer 2014년 6월 4일
my first guess would be, that in your Java program the search path from Windows is not the same, i.e., it's missing the folder c:\program files\matlab\MATLAB Compiler Runtime\v715\runtime\winXY folder...?

Community Treasure Hunt

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

Start Hunting!

Translated by