Main Content

Java Package Integration

Integrate compiled MATLAB® functions into Java® applications

With MATLAB Compiler SDK™, integrating compiled MATLAB functions into a Java application involves using a combination of APIs that initialize MATLAB Runtime, load the compiled MATLAB functions into MATLAB Runtime, and manage the data that passes between Java and MATLAB.

Java packages and applications provide portable and scalable solutions for applications in large-scale enterprise or web environments. You can deploy generated packages to enterprise or web environments where MATLAB Runtime is installed.

Java Remote Method Invocation (RMI) is a set of APIs that enable Java objects to invoke objects in a different Java virtual machine (JVM). Use RMI to develop client-server applications, distributed applications, and web applications. For such applications, only the portions of the application that directly invoke MATLAB functions require MATLAB Runtime. The other portions of the application can work with native Java data types.

Functions

compiler.build.javaPackageCreate Java package for deployment outside MATLAB (Since R2021a)
compiler.build.JavaPackageOptionsOptions for building Java packages (Since R2021a)
compiler.build.ResultsCompiler build results object (Since R2020b)
mcrinstallerDisplay version and location information for MATLAB Runtime installer corresponding to current platform
mcrversionReturn MATLAB Runtime version number that matches MATLAB version

Java API Documentation

Classes

expand all

com.mathworks.extern.java.MWArray Abstract Java base class to manage array types in MATLAB
com.mathworks.extern.java.MWCellArray Java class to manage MATLAB cell arrays

Data Type Representation

com.mathworks.toolbox.javabuilder.MWArray Java class to serve as base for all MATLAB array types with native array handling
com.mathworks.toolbox.javabuilder.MWCellArray Java class to manage MATLAB cell arrays
com.mathworks.toolbox.javabuilder.MWCharArray Java class to manage MATLAB character arrays
com.mathworks.toolbox.javabuilder.MWNumericArray Java class to manage numeric arrays in MATLAB
com.mathworks.toolbox.javabuilder.MWStringArray Java class to manage MATLAB string arrays
com.mathworks.toolbox.javabuilder.MWStructArray Java class to manage MATLAB struct arrays
com.mathworks.toolbox.javabuilder.MWLogicalArray Java class to manage MATLAB logical arrays
com.mathworks.toolbox.javabuilder.MWComplexity Java class to enumerate MATLAB array complexity properties
com.mathworks.toolbox.javabuilder.MWFunctionHandle Java class to represent function handles in MATLAB
com.mathworks.toolbox.javabuilder.MWClassID Java class to enumerate all MATLAB array types

MATLAB Runtime Management

com.mathworks.toolbox.javabuilder.MWApplication Java class to initialize and manage MATLAB Runtime global state
com.mathworks.toolbox.javabuilder.MWMCROption Java class to specify MATLAB Runtime initialization options

Code Archive (.ctf File) Management

com.mathworks.toolbox.javabuilder.MWCtfClassLoaderSource Java class to manage code archive (.ctf file) sources from class loader in MATLAB
com.mathworks.toolbox.javabuilder.MWCtfExtractLocation Java class to manage code archive (.ctf file) extraction locations in MATLAB
com.mathworks.toolbox.javabuilder.MWCtfFileSource Java class to handle code archive (.ctf file) file sources in MATLAB
com.mathworks.toolbox.javabuilder.MWCtfSource Java interface to interact with code archive (.ctf file) sources in MATLAB
com.mathworks.toolbox.javabuilder.MWCtfStreamSource Java class to manage code archive (.ctf file) stream sources in MATLAB

Other

com.mathworks.toolbox.javabuilder.Images Java utility methods for image data manipulation within MWArrays
com.mathworks.toolbox.javabuilder.MWComponentOptions Java class to manage component instance options in MATLAB
com.mathworks.toolbox.javabuilder.MWJavaObjectRef Java class to create a MATLAB array that references aJava object
com.mathworks.toolbox.javabuilder.MWMatrixRef Java class to represent matrix references in MATLAB

Interfaces

Interface Disposable Java interface for releasing native resources used by classes
Interface MWComponentOption Java interface for component initialization options

Exceptions

com.mathworks.toolbox.javabuilder.MWException Java class to handle exceptions in MATLAB Compiler generated artifacts

Remoting Classes

com.mathworks.toolbox.javabuilder.remoting.AbstractMWArrayVisitor<T> Abstract Java class to provide visitor pattern for array types
com.mathworks.toolbox.javabuilder.remoting.BasicRemoteFactory Java class to implement RemoteFactory interface
com.mathworks.toolbox.javabuilder.remoting.NativeArrayContainer Java class to ensure proper disposal of automatically created arrays in remote proxies
com.mathworks.toolbox.javabuilder.remoting.RemoteProxy Java class to dynamically generate remote proxies for local object access via RMI

Interfaces

Interface DisposeListener Java interface for listening to remote proxy object disposal
Interface MWArrayVisitor<T> Java interface to define array visitor behavior
Interface RemoteFactory Java interface to factory for remote proxy objects

Topics

Requirements and Highlights

Create and Integrate with Java

Sample Applications

Data Management

Deployment Considerations

Remote Method Invocation

Troubleshooting Java Packages