MATLAB: Does the contents of javaclasspath.txt not get added to the static class path when I double-click on an M-file to start MATLAB 8.1 (R2013a)

classpathjavaMATLABpropertiesstartup

When I start MATLAB by double-clicking on a MATLAB shortcut icon, the path given in javaclasspath.txt gets added to the static path. But if I start MATLAB by opening an M-file, this path does not get added.

Best Answer

The following conditions apply depending on where you place the javaclasspath.txt:
1. If javaclasspath.txt is placed in the startup folder or the preferences folder and MATLAB is started by clicking on a shortcut (MATLAB icon), the contents of javaclasspath.txt will be loaded.
2. If javaclasspath.txt is placed in the startup folder (not in the preferences folder) and MATLAB is started by clicking on an M-file, the contents of javaclasspath.txt will not be loaded.
3. If javaclasspath.txt is placed in the preferences folder (not in the startup folder) and MATLAB is started by clicking on an M-file, the contents of javaclasspath.txt will be loaded.
The preferences folder location can be found using the following command at the MATLAB prompt:
prefdir
Place your javaclasspath.txt file in that folder and when you click on an M-file (that then loads MATLAB) you should see the contents of javaclasspath.txt on the static class path.