External Interfaces Previous page   Next Page

Simplifying Java Class Names

Your MATLAB commands can refer to any Java class by its fully qualified name, which includes its package name. For example, the following are fully qualified names:

A fully qualified name can be rather long, making commands and functions, such as constructors, cumbersome to edit and to read. You can refer to classes by the class name alone (without a package name) if you, first, import the fully qualified name into MATLAB.

The import command has the following forms.

MATLAB adds all classes that you import to a list called the import list. You can see what classes are on that list by typing import, without any arguments. Your code can refer to any class on the list by class name alone.

When called from a function, import adds the specified classes to the import list in effect for that function. When invoked at the command prompt, import uses the base import list for your MATLAB environment.

For example, suppose a function contains the following statements.

Code that follows the import statements above can now refer to the String, Frame, and Enumeration classes without using the package names.

To clear the list of imported Java classes, invoke the command


Previous page  Loading Java Class Definitions Locating Native Method Libraries Next page

© 1994-2005 The MathWorks, Inc.