Skip to Main Content Skip to Search
Product Documentation

MATLAB Builder JA Prerequisites

Your Role in the Java Application Deployment Process

Depending on the size of your organization, you may play one role, or many, in the process of successfully deploying a Java application.

For example, your job may be to analyze user requirements and satisfy them by writing a program in MATLAB code. Or, your role may be to implement the infrastructure needed to successfully deploy a Java application to the Web. In smaller installations, you may find one person responsible for performing tasks associated with multiple roles.

The table Application Deployment Roles, Tasks, and References describes some of the different roles, or jobs, that MATLAB Builder JA users typically perform and which tasks they would most likely perform when running The Magic Square Example.

Application Deployment Roles, Tasks, and References

RoleTasksReferences
MATLAB programmer
  • Understand end-user business requirements and the mathematical models needed to support them.

  • Write MATLAB code.

  • Build an executable component with MATLAB tools (usually with support from a Java developer).

  • Package the component for distribution to end users.

  • Pass the packaged component to the Java developer for rollout and further integration into the end-user environment.

Copying the Example Files

Testing the MATLAB File You Want to Deploy

Creating the Magic Square Java Component

Packaging the Magic Square Java Component (Optional)

Copy the Package You Created (Optional)

Java developer
  • Write Java code to execute the Java package built by the MATLAB programmer.

  • Roll out the packaged component and integrate it into the end-user environment.

  • Use the component in enterprise Java applications, adding and modifying code as needed.

  • Address data conversion issues that may be encountered, according to the end user's specifications.

  • Ensure the final Java application executes reliably in the end user's environment.

Gathering Files Needed for Deployment

Testing the Java Component in a Java Application

Distribute MATLAB Code Using the MATLAB Compiler Runtime (MCR)

Calling Class Methods from Java

Handle Data Conversion as Needed

Build and Test

End userExecute the solution created by MATLAB and Java developers.Run the deployed application (outside the scope of this document).

What You Need to Know

The following knowledge is assumed when you use the MATLAB Builder JA product:

Required Products

You must install the following products to run the example described in this chapter:

Dependency and Non-Compilable Code Considerations

Before you deploy your code, examine the code for dependencies on functions that may not be compatible with MATLAB Compiler.

For more detailed information about dependency analysis (depfun) and how MATLAB Compiler evaluates MATLAB code prior to compilation, see MATLAB Code Deployment in the MATLAB Compiler User's Guide.

Configuring Your Environment

Systems Administrator

RoleKnowledge BaseResponsibilities

Systems administrator
  • No MATLAB experience

  • Access to IT Systems

  • IT expert

  • Gets updates to a deployed component or the larger application out to end users

  • Manages versions of the application for end users

  • Manages versions of the MCR

  • Manages versions of the JDK

Configure your environment to work with the examples. Consult your system administrator or Java developer before performing these tasks—some may be unnecessary. Your administrator or programmer is often the best resource for verifying, installing, or customizing your Java environment.

Verifying Your Java Environment

You may already be running a compatible version of Java. To find out if you have Java installed on your computer, and if it is compatible with the MATLAB Builder JA product:

  1. Open a command prompt.

  2. Enter the command java -version. If Java is installed, the result looks like this:

    java version "version_number"
    Java(TM) 2 Runtime Environment, Standard Edition 
    (build version_number.build_number
    Java HotSpot(TM) Client VM 
         (build version_number.build_number, mixed mode)
  3. Enter the command javac -version.

      Note   Alternately, you may have to enter %JAVA_HOME%\bin\javac -version if you have the user environment variable JAVA_HOME defined. For information on locating environment variables, see Setting Up Your Java Environment.

    If javac is installed, the results should look like this:

    javac version_number

If java and javac are installed, go to The Magic Square Example. If not, go to Setting Up Your Java Environment.

Setting Up Your Java Environment

  1. Download and install the Java Developer's Kit (JDK) from Sun Microsystems™, Inc. if you do not yet have it installed.

    The JDK is a collection of Java classes, run-time environment, compiler, debugger, and usually source code, for a version of Java. The contents of the JDK collectively make up a Java development environment.

    The JDK includes the Java Runtime Environment (JRE), a collection of compiled classes that makes up the Java virtual machine, a standalone executor of the Java language, on a specific platform.

      Note   You should be using the same version of Java that ships with MATLAB. To find out what version of Java MATLAB is running, enter the following MATLAB command:

      version -java

        Caution   MathWorks only supports the Sun JDK and JRE. A certain measure of cross-version compatibility resides in the Sun software and it may be possible to run MCR-based components with non-Sun JDK's under some circumstances—however, compatibility is not guaranteed.

  2. Set the environment variable JAVA_HOME. This tells Java where to find your installed JDK. from the MATLAB prompt. You can set JAVA_HOME:

    • On Windows platforms:

      1. Right-click the My Computer icon and select Properties.

      2. Click the Advanced tab.

      3. Click Environment Variables.

      4. In the User Variables area, click New.

      5. In the New User Variable dialog box, enter JAVA_HOME for Variable name. Enter the absolute path name where your JDK is installed for Variable value. Here is the value of a typical JAVA_HOME environment variable:

        C:\Program Files\Java\JDK1.6.0_03

          Note   If JAVA_HOME already exists, select it and click Edit. Enter the path name where your JDK is installed.

      6. Click OK to accept changes.

    • On UNIX platforms:

      1. Open a command prompt.

      2. Set JAVA_HOME as follows:

        set JAVA_HOME=JDK_pathname

      Note   When using the Bash or C (csh) shells, the command is somewhat different. The Bash shell uses export in place of set. csh uses setenv.

    to set the variable. Although this may work in a specific shell; this won't do the trick in the commonly used bash (need to use "export") or csh (need to use "setenv") (based) shells. So we may want to change the instructions.

  3. Verify that MATLAB is reading the correct value of JAVA_HOME.

    1. At the command prompt, type getenv JAVA_HOME.

    2. The response from MATLAB should be the path name you set to JAVA_HOME in Configuring Your Environment. If not, ensure the JDK that MATLAB is pointing to will be compatible to run this example. Consult your system administrator if you are unsure.

        Note   You should be using the same version of Java that ships with MATLAB. To find out what version of Java MATLAB is running, enter the following MATLAB command:

        version -java

          Caution   MathWorks only supports the Sun JDK and JRE. A certain measure of cross-version compatibility resides in the Sun software and it may be possible to run MCR-based components with non-Sun JDK's under some circumstances—however, compatibility is not guaranteed.

  


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