Why does an application which uses Java and was generated by the MATLAB Compiler 4.0 (R14) fail to run when I deploy it to a new system?

1 view (last 30 days)
I have an application generated by the MATLAB Compiler 4.0 (R14) which calls into a Java class. When I deploy it to a target computer I receive the following error:
Undefined variable "com" or class "com.mathworks.toolbox.<classname>".
I do not receive this error on the development system.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Oct 2017
This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
This error occurs because the compiled application fails to correctly set the CLASSPATH variable to point to the JAR-files which are included in the associated CTF-file (and extracted to the corresponding $APPNAME_mcr directory where $APPNAME is the name of your application). At runtime, the application is searching for the JAR-file in $MCR, the directory in which MCRINSTALLER was installed instead of the directory $APPNAME_mcr.
This error has been fixed in MATLAB Compiler 4.1 (R14SP1) and later.
In order to resolve this with version 4.0 (R14), extract the CTF-file either with the extractCTF utility described at:
Extracting a CTF Archive without Executing the Component :: Deployment Process (MATLAB Compiler)
or by running the application once and allowing it to error.
Copy the JAR-file referenced in the error message from its location in $APPNAME_mcr ($APPNAME_mcr/java/jar/toolbox for MATLAB toolboxes) to the corresponding location in $MCR (most likely $MCR/MATLAB Component Runtime/v70/java/jar/toolbox).
When you run your application, it will find the JAR-file in the $MCR directory.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!