Main Content

Call Java from MATLAB

Directly call Java® library functionality from MATLAB®

You can access existing Java classes to use in the MATLAB workspace. For example, use built-in class packages, such as java.util, which are included in the Java language. See your Java language documentation for descriptions of these packages. You also can access classes defined in individual .class files, packages, or Java Archive (JAR) files, including classes you develop.

You can run MATLAB with your system version of the Java Runtime Environment (JRE™). For information about Java versions compatible with MATLAB, see MATLAB Interfaces to Other Languages. To set the JRE path in MATLAB, call jenv. To set the path from the operating system prompt, call matlab_jenv.

If instead you want to call MATLAB functions from Java applications, see Call MATLAB from Java.

Funktionen

isjavaDetermine if input is Java object
javaaddpathAdd entries to dynamic Java class path
javaArrayConstruct Java array object
javachkError message based on Java feature support
javaclasspathReturn Java class path or specify dynamic path
javaMethodCall Java method
javaMethodEDTCall Java method from Event Dispatch Thread (EDT)
javaObjectCall Java constructor
javaObjectEDTCall Java constructor on Event Dispatch Thread (EDT)
javarmpathRemove entries from dynamic Java class path
usejavaDetermine if Java feature is available
jenvSet Java path for MATLAB (Seit R2021b)
matlab_jenvSet the Java path for MATLAB from system prompt (Seit R2021b)

Objekte

JavaEnvironmentJava environment information (Seit R2023a)

Klassen

matlab.exception.JavaExceptionCapture error information for Java exception

Themen

Getting Started

Using Java Libraries

Fehlersuche

Java Heap Memory Preferences

How to adjust the Java heap size.

Avoid Calling Java main Methods in MATLAB

How MATLAB handles main methods.