MATLAB: (noob) Matlab Compiler Issue

javaMATLAB Compiler

Hey folks,
I am trying to build an m-file (sans GUI) into a standalone application for colleagues to utilize.
Unfortunately, the compiler immediately exits in error when I hit Package. here is the packagingLog:
ant:
<ant>
<mkdir dir="C:\Users\hb69954\Documents\MATLAB\kairos\SugaredOwl\for_redistribution" />
<mkdir dir="C:\Users\hb69954\Documents\MATLAB\kairos\SugaredOwl\for_testing" />
<mkdir dir="C:\Users\hb69954\Documents\MATLAB\kairos\SugaredOwl\for_redistribution_files_only" />
</ant>
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/Project
at com.mathworks.project.impl.engine.AntEntryPoint.main(AntEntryPoint.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.Project
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
My assumption here is I am missing a java library, could anyone point me in the right direction?

Best Answer

The "NoClassDefFoundError" error is thrown because MATLAB is not able to locate Java Runtime libraries that are used by the MATLAB Compiler SDK.
There are several possible causes to this issue:
A. The installation is corrupted and there are .jar files missing from the MATLAB installation folder.
B. The classpath.txt file is missing references to Java Runtime libraries.
1. To take a look at the MATLAB search path, execute "pathtool" in the Command Window. This will open up the Set Path window with the list of folders that MATLAB parses. The start-up folder should be at the top.
You can try to restore the search path to the installation default by executing the following commands:
>> restoredefaultpath
>> rehash toolboxcache
However, this will not remove the start-up directory from the MATLAB search path. If the start-up folder contains M-files, try to remove them or move them to another folder which is not on the search path.
2. If the issue still persists, the installation might be corrupted. Remove MATLAB completely and install it again to resolve the issue.
Related Question