MATLAB: Do I receive a “Failed to find the runtime libraries” error when running a MATLAB Builder JA 2.0.1 (R2008a) component in Windows

MATLAB Compiler SDK

I have compiled my function MATLAB file(s) into one or more Java classes contained in a JAR-file (.jar) component. I am using the classes in my external Java driver application, and developing the application outside of MATLAB, in a text editor or IDE.
When executing my driver application, I get the following error when initializing an instance of a MATLAB-compiled class in my code. This is despite the fact that I have specified all the necessary file paths in my -CLASSPATH argument to the Java compiler (javac.exe).
java.lang.Exception: Failed to find the runtime libraries, required by
MATLAB Builder JA, on system path
at com.mathworks.toolbox.javabuilder.internal.MWMCR.getMLorMCRRuntimeLibDir(MWMCR.java:1532)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1434)
at magicsquare.magicsquareMCRFactory.<clinit>(magicsquareMCRFactory.java:101)
at magicsquare.magic.main(magic.java:99)
java.lang.UnsatisfiedLinkError: mclIsStandaloneMode
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclIsStandaloneMode(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.getNativeMCR(MWMCR.java:746)
at magicsquare.magicsquareMCRFactory.createComponentData(magicsquareMCRFactory.java:110)
at magicsquare.magicsquareMCRFactory.<clinit>(magicsquareMCRFactory.java:101)
at magicsquare.magic.main(magic.java:99)

Best Answer

You are receiving this error because the required "bin" directories of either the MATLAB or MATLAB Compiler Runtime (MCR) installations have not been set up correctly on your Windows machine's PATH environment variable. You can make the necessary runtime libraries visible to MATLAB-compiled components by adding either:
[matlabroot]\bin\win32
or
[mcr_root]\[version]\runtime\win32
to your system PATH, depending on whether you are developing against a local MATLAB installation, or the MCR. Either replace [matlabroot] with the MATLAB installation directory on your machine (e.g., C:\Program Files\MATLAB\R2008a), or [mcr_root] with the MCR installation directory (e.g., C:\Program Files\MATLAB\MATLAB Compiler Runtime) and [version] with the version of the installed MCR (e.g., v78).
A comprehensive overview of the directories required for development, testing, and runtime deployment of MATLAB-compiled components is provided in the following MATLAB Help pages:
At these Help pages, pay particular attention to the special considerations that must be taken when when deploying Java components.
As reference, the following Help page in "Compiler Tips" is also of relevance: