Skip to Main Content Skip to Search
Product Documentation

Product Overview

MATLAB Compiler Extension

MATLAB® Builder™ JA enables you to create Java™ classes from your MATLAB® programs. These Java classes can be integrated into Java programs and deployed royalty-free to desktop computers or Web servers that do not have MATLAB installed.

When used with MATLAB Compiler™, the builder creates deployable components that make MATLAB based computations, visualizations, and graphical user interfaces accessible to end users of the Java programs.

When the Java program is deployed to the Web, multiple users can access it through a Web browser.

The builder encrypts your MATLAB functions and generates a Java wrapper around them so that they behave just like any other Java class. Java classes created with MATLAB Builder JA are portable and run on all platforms supported by MATLAB. See the Platform Roadmap for MATLAB® for more information.

For information about how MATLAB® Compiler™ works, see How Does MATLAB Compiler Software Build My Application?

How MATLAB Builder JA Works

MATLAB Builder JA produces JAR files ("generated components") that depend on javabuilder.jar, which ship with the MATLAB Builder JA toolbox.javabuilder.jar requires a matching version of the MCR be installed on the same machine running the Java application.

When the class contained within javabuilder.jar is instantiated for the first time, a series of events occur:

  1. Dependent classes in javabuilder.jar are loaded.

  2. The static initialization of dependent classes triggers the loading of a series of shared libraries (contained within the MATLAB Compiler Runtime (MCR)).

    The shared libraries implement a number of native methods which form the bridge from the generated MATLAB Builder JA component to the MCR's implementation of the MATLAB language runtime.

  3. Once the shared libraries are loaded, the MATLAB language runtime is initialized by creating an instance of a C++ class called mcrInstance.

  4. The construction of mcrInstance triggers the initialization of many of the subsystems that comprise the MATLAB language runtime environment. One such subsystem is the MATLAB-Java™ language interface, which allows MATLAB programs to call Java code directly.

    When the MCR's native code is loaded into a running JVM, as is the case with a MATLAB Builder JA generated component, the MATLAB-Java interface subsystem establishes a connection to the already running JVM by calling the JNI method AttachCurrentThread.

  5. AttachCurrentThread creates a class loader that loads all classes needed by MATLAB code utilizing the MATLAB-Java interface. These include infrastructure classes required by the interface itself, as well as user-defined classes explicitly imported from MATLAB code.

  6. The static constructors of the classes within javabuilder.jar install a shutdown hook to explicitly terminate the MCR's threads and release its resources. This process is predicated on the JVM entering the shutdown state and on all generated component class instances being released via their dispose method. If you fail to call dispose, native threads running during shutdown will cause undefined and unexpected behavior in the JVM.

How the MATLAB Compiler and MATLAB Builder JA Products Work Together

The MATLAB Compiler product can compile MATLAB files, MEX-files, MATLAB objects, or other MATLAB code. The MATLAB Builder JA product supports all the features of MATLAB, and adds support for Java classes, Java objects (instances of a class), and methods. Using these products together, you can generate the following:

How Does Component Deployment Work?

There are two kinds of deployment:

Limitations of Support

MATLAB Builder JA provides a wide variety of support for various Java types and objects. However, MATLAB (MCOS) objects are not supported as inputs or outputs for compiled or deployed functions.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS