User`s manual

Bringing Java Classes into MATLAB
5-7
and JAR files, consult your Java development documentation or the JavaSoft
web site. See also “To Learn More About Java Programming” on page 5-3.
To make the contents of a JAR file available for use in MATLAB, add to
classpath.txt the full path, including full filename, for the JAR file.
Note Note that the classpath.txt requirement for JAR files is different
than that for
.class files and packages, for which you do not specify any
filename.
For example, to make available the JAR file
e:\java\classes\utilpkg.jar,
add the following to your
classpath.txt.
e:\java\classes\utilpkg.jar
Finding and Editing classpath.txt
To make your Java classes available, you can edit the default classpath.txt,
which is in the directory
toolbox/local. Or, you can copy the default
classpath.txt from this directory to your own startup directory where the
changes you make to it do not affect anyone else.
To find the
classpath.txt that is used by your MATLAB environment, use the
MATLAB
which function.
which classpath.txt
To edit either the default file or the copy you have made in your own directory,
enter the following command in MATLAB.
edit classpath.txt
MATLAB reads classpath.txt only upon startup. So, if you edit
classpath.txt or change your .class files while MATLAB is running, you
must restart MATLAB to put those changes into effect.
Loading Java Class Definitions
Normally, MATLAB loads a Java class automatically when your code first uses
it, (for example, when you call its constructor). However, there is one exception
that you should be aware of.