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

6 views (last 30 days)
Hello,
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
c("C:\\Users\\cimlUser\\Desktop\\JAVA\\DiffusionLaw\\DiffusionLaw.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.

Accepted Answer

Sébastien MAILFERT
Sébastien MAILFERT on 4 Jun 2014
Edited: Sébastien MAILFERT on 4 Jun 2014
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 Comments
Titus Edelhofer
Titus Edelhofer on 4 Jun 2014
Yes, I meant this part. And no, the path should contain the MCR win32 folder. The exe is found because you provide the full path ... Although I'm wondering now: if you start the .exe, the path is known. When you start your java program, somehow (parts) of the path get lost? Any idea why?
Sébastien MAILFERT
Sébastien MAILFERT on 6 Jun 2014
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

Sign in to comment.

More Answers (1)

Titus Edelhofer
Titus Edelhofer on 4 Jun 2014
Hi,
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...?
Titus

Community Treasure Hunt

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

Start Hunting!