MATLAB® loads Java® class definitions from files that are on the Java class path. The Java class path is segmented into a static path and a dynamic path. Keep the following in mind when you determine if Java class definitions are static or dynamic path entries.
When packaging a toolbox, JAR files are detected so they can be included on the dynamic path.
The dynamic path is convenient but intended for development and debugging. When packaging your toolbox, consider instructing your users to add your Java classes to their static path.
The static path offers better class loading performance than the dynamic path.
Modifying the static path, requires MATLAB to be restarted. You can change the dynamic path without restarting MATLAB.
Classes on the static path run the same way as they do in Java. Classes on the dynamic path might not behave the same as classes on the static path.
Classes on the static path cannot have dependencies on classes on the dynamic path.
For more information about static and dynamic Java class paths, see Java Class Path.
You can specify files to include on the user's dynamic Java class path when they install the toolbox. MATLAB automatically detects JAR files to include in the toolbox. When packaging a toolbox, review the entries under Java Class Path in the Install Actions section of the Package a Toolbox dialog box. These files are added to the user's dynamic Java class path when they install the toolbox.
If Java classes need to be on the static class path, it is good practice to include information with your toolbox to help users modify their static paths. For example, to include static Java class path entries in your toolbox:
Provide a classpath.txt
file in
the toolbox root with the relative path entries for Java files.
If Java files are located outside of your toolbox root, make
sure that they are listed under External Files when
you package your toolbox.
Provide instructions for the user to modify their
static path via a readme.txt
file or your toolbox
documentation. To modify their static path, the user must add your
static entries to their javaclasspath.txt
. They
might have to create this file and they will need to restart MATLAB.
For more information, see Static Path.
javaaddpath
| javaclasspath
| javarmpath