| Contents | Index |
| On this page… |
|---|
How the MATLAB Compiler and MATLAB Builder JA Products Work Together |
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?
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:
Dependent classes in javabuilder.jar are loaded.
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.
Once the shared libraries are loaded, the MATLAB language runtime is initialized by creating an instance of a C++ class called mcrInstance.
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.
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.
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.
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:
Standalone applications on UNIX®, Windows®, and Macintosh® platforms
C and C++ shared libraries (dynamically linked libraries, or DLLs, on Microsoft® Windows)
Enterprise Java applications for use on any Java compatible platform
There are two kinds of deployment:
Installing components and setting up support for them on a development machine so that they can be accessed by a developer who seeks to use them in writing a Java application.
Deploying support for the components when they are accessed at run time on an end user machine.
To accomplish this kind of deployment, you must make sure that the installer you create for the application takes care of supporting the Java components on the target machine. In general, this means the MCR must be installed, on the target machine. You must also install the MATLAB Builder JA component.
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.
![]() | Getting Started | MATLAB Builder JA Prerequisites | ![]() |

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 |