User`s manual

5 Calling Java from MATLAB
5-6
1.1.8 Java Virtual Machine from the web site at Sun Microsystems, (http://
www.java.sun.com/jdk/
). The Sun site also provides documentation for the
Java language and classes that you will need for development.
After you create class definitions in
.java files, use your Java compiler to
produce
.class files from them. The next step is to make the class definitions
in those
.class files available for you to use in MATLAB.
Making Java Classes Available to MATLAB
To make your third-party and user-defined Java classes available in MATLAB,
place them on your MATLAB path by adding their locations to the file
classpath.txt. For more information on classpath.txt, see “Finding and
Editing classpath.txt” on page 5-7.
Making Individual (Unpackaged) Classes Available
To make individual classes (classes not part of a package) available in
MATLAB, add to
classpath.txt an entry containing 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 your
classpath.txt file.
d:\work\javaclasses
Making Entire Packages Available
To access one or more classes belonging to a package, you need to make the
entire package available to MATLAB. Do this by adding to
classpath.txt 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 entry to your
classpath.txt.
d:\work
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