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

3 次查看(过去 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
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
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 CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by