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 the 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
compiler.build.JavaPackageOptionsOptions for building Java packages
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

Topics

Create and Integrate with Java

Generate Java Package and Build Java Application

Create a Java package in MATLAB and implement it with sample Java code.

Sample Applications

Integrate Simple MATLAB Function Into Java Application

Learn how to integrate a MATLAB generated Java package into a Java application.

Display MATLAB Plot in Java Application

Build a Java application that displays a MATLAB plot.

Create Java Phone Book Application Using Structure Array

Encapsulate a MATLAB function that modifies a structure array containing phone numbers.

Create Java Application with Multiple MATLAB Functions

Implement a signal analyzer application that incorporates multiple functions using dependency analysis.

Assign Multiple MATLAB Functions to Java Class

Create a Java package containing multiple functions to implement a matrix math program.

Use MATLAB Class in Java Application

Use object-oriented design to deploy a MATLAB class in a Java package.

Pass Java Objects to MATLAB

Build a Java package that applies optimization routines to objective functions using the MWJavaObjectRef class.

Block Console Display When Creating Figures in Java

Use waitForFigures in a console-based Java application that generates MATLAB figures.

Data Management

Convert Data Between Java and MATLAB

See guidelines on how to convert data between Java and MATLAB.

Rules for Data Conversion Between Java and MATLAB

Refer to the rules for converting Java types to MATLAB types.

Manage MATLAB Resources in JVM

Properly create and dispose of MATLAB data in your code.

Render MATLAB Image Data in Java

See techniques to work effectively with figure and image data in your code.

Deployment Considerations

Define Embedding and Extraction Options for Deployable Java Archive

Manage deployable archive embedding and extraction behavior using either the MWComponentOptions class or environment variables.

Ensure Multiplatform Portability for Java

Ensure platform independence in your compiled MATLAB code.

Limitations on Multiple Packages in Single Java Application

Learn the data types that cannot be shared across Java packages.

Remote Method Invocation

Remote Method Invocation for Client-Server Applications

Learn how RMI allows you to run separate processes on multiple machines.

Run Client and Server Using RMI

Try an example using RMI with a client and server.

Represent Native Java Cell and Struct Arrays

See an example illustrating the use of native Java cell and struct arrays.