Call Method in Your Own Java Class - MATLAB & Simulink (original) (raw)

Main Content

To define new Java® classes and subclasses of existing classes, use a Java Development Kit external to MATLAB®. For version information, see Versions of OpenJDK Compatible with MATLAB by Release.

After you create class definitions in .java files, use your Java compiler to produce .class files. The next step is to make the class definitions in those .class files available for you to use in MATLAB.

This example shows how to call a method in your own Java class. The example uses a class file named_myclass.class_ in the folderC:\Documents\MATLAB\ containing a method_package.myclass.mymethod(params)_.

Put the class file on the dynamic Java class path, making the class available in the current MATLAB session only. MATLAB provides the dynamic path as a convenience for when you develop your own Java classes.

See Also

javaaddpath

Topics