External Interfaces Previous page   Next Page

Making Java Classes Available to MATLAB

To make your third-party and user-defined Java classes available in MATLAB, place them on either the static or dynamic Java class path, as described in the previous section, The Java Class Path.

Making Individual (Unpackaged) Classes Available

To make individual classes (classes that are not part of a package) available in MATLAB, specify the full path to the directory you want to use for the .class file(s).

For example, to make available your compiled Java classes in the file d:\work\javaclasses\test.class, add the following entry to the static or dynamic class path:

To put this directory on the static class path, add the above line to the default copy (in toolbox\local) or your own local copy of classpath.txt. See Finding and Editing classpath.txt.

To put this on the dynamic class path, use the following command:

Making Entire Packages Available

To access one or more classes belonging to a package, you need to make the entire package available to MATLAB. To do this, specify the full path to the parent directory of the highest-level directory of the package path. This directory is the first component in the package name.

For example, if your Java class package com.mw.tbx.ini has its classes in directory d:\work\com\mw\tbx\ini, add the following directory to your static or dynamic class path:

Making Classes in a JAR File Available

You can use the jar (Java Archive) tool to create a JAR file, containing multiple Java classes and packages in a compressed ZIP format. For information on jar and JAR files, consult your Java development documentation or the JavaSoft web site. See also To Learn More About Java Programming.

To make the contents of a JAR file available for use in MATLAB, specify the full path, including full filename, for the JAR file.

For example, to make available the JAR file e:\java\classes\utilpkg.jar, add the following file specification to your static or dynamic class path:


Previous page  The Java Class Path Loading Java Class Definitions Next page

© 1994-2005 The MathWorks, Inc.