MATLAB: Deploying Java Package – Error – Failed to find the library mclmcrrt7_16.dll

javajavabuilderMATLAB CompilerMATLAB Compiler SDK

Hi,
I've created a Java Package on Matlab. However, when try to call the created class from a java app, i get the error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the library mclmcrrt7_16.dll, required by MATLAB Builder JA, on java.library.path. This library is typically installed along with MATLAB or the MCR, its absence may indicate an issue with that installation or the current path configuration. The MCR version that this component is trying to use is: 7.16.
I've checked the path environment variable and this dll is located one of the paths – ie. c:\Program Files\MATLAB\R2011b\runtime\win64.
A couple of things though. When i compile the java package using javac version 1.7.0_02 I don't get this problem. But when i change the path environment variable to point at version 1.6.0_29, this problem crops up. (I have to build using version 1.6 as I'm using repast java which runs on 1.6 – it kicks up lots of errors when i try to run my app using JRE 7/JSE 1.7).
ALso, I'm running the java app on the same machine that matlab was installed on.
Any ideas?
Thanks,
Eoin

Best Answer

Hi Eoin,
Your MATLAB install shipped with a specific JVM version. A MATLAB install is only fully supported on the JVM version it is shipped with. Check what version your MATLAB install shipped with via the following command.
version -java
MATLAB R2011b 32 bit, for example, shipped with 'Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode'. MATLAB R2011b shipped with 'Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode'.
From this I suggest you launch your Java application in a 32 bit runtime environment at least up to date with the MATLAB bundled software if you have MATLAB R2011b 32 bit installed and a 64 bit runtime environment if you have MATLAB R2011b 64 bit.
I would guess that at the time of writing this you were on a MATLAB 64 bit install, your 1.6 JDK was 32 bit, and your 1.7 JDK was 64 bit. I hope this shows the mismatch in your setup. I am not saying this is the only setup that will work, but it is at least a functional starting point.
Cheers, Kyle