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

6 ビュー (過去 30 日間)
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.

採用された回答

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 件のコメント
Titus Edelhofer
Titus Edelhofer 2014 年 6 月 4 日
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 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 日
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

カテゴリ

Help Center および File ExchangeCall Java from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by