MATLAB: Do I get an ‘Undefined variable “com” or class’ error when running a toolbox from File Exchange

classdependencydynamicjavaMATLABpackagepathstaticzip

I have downloaded a zip file from File Exchange, extracted the directory, and opened the directory from MATLAB. I run the toolbox command and encounter the following error:
"Undefined variable "com" or class "com.xxx.xxx". 

Best Answer

The error is encountered when a java dependency is not detected in the Java class path. This may happen when the toolbox is not fully added to MATLAB.
To add a zipped File Exchange toolbox to MATLAB, the general process is as follows:
1. Extract the ZIP file
2. From the "Current Folder" window in MATLAB, right-click on the extracted folder and select "Add to Path", then "Selected Folders and Subfolders"
Certain toolboxes may contain additional JAR files that need to be added to the JAVACLASSPATH for the toolbox to run correctly.
You can add the JAR files to the dynamic class path using the 'javaaddpath' command.
To automatically load the JAR files every time MATLAB starts, you can add the jar files to the static class path from the 'javaclasspath.txt' file. You can find more information on how to do so in the following link: