Main Content

Java Class Path

To make Java® classes available to MATLAB®, place them on the Java class path. The class path is a series of file and folder specifications. When loading a Java class, MATLAB searches the files and folders in the order they occur on the class path. The search ends when MATLAB finds a file that contains the class definition.

Built-in Java class packages—classes in the Java standard libraries—are already on the class path. You do not need to modify the path to access these classes.

To access Java classes from MATLAB, add them to the class path. For information and examples, see Static Path.

  • JAR File Classes

  • Packages

  • Individual (unpackaged) classes

MATLAB segments the Java class path into a static path and a dynamic path. MATLAB searches the static path before the dynamic path.

  • Use the static path as the default path to load a Java class.

  • Use the dynamic path when developing your own Java classes. You can modify and load the dynamic path any time during a MATLAB session.

Java Class Path OptionsAction

Display class path

Call the javaclasspath function.

Add files to static path

Create an ASCII text file named javaclasspath.txt in your preferences folder. For information and examples, see Static Path.

Add or remove files on dynamic path

Call the javaclasspath, javaaddpath, or javarmpath functions. These functions clear all existing variables and global variables in the workspace. For more information, see Dynamic Path.

Augment search path for native method libraries.

Create an ASCII text file named javalibrarypath.txt in your preferences folder. For information, see Locate Native Method Libraries.

See Also

Related Examples

More About