| Contents | Index |
| On this page… |
|---|
System requirements and restrictions on use for the MATLAB Builder JA product are as follows:
All requirements for the MATLAB Compiler product; see Installation and Configuration in the MATLAB Compiler documentation.
Java Development Kit must be installed.
Java Runtime Environment (JRE) that is used by MATLAB and MCR.
In order to use some screen-readers or assistive technologies, such as JAWS®, you must add the following DLLs to your Windows path:
JavaAccessBridge.dll WindowsAccessBridge.dll
You may not be able to use such technologies without doing so.
In general, limitations and restrictions on the use of the MATLAB Builder JA product are the same as those for the MATLAB Compiler product. See Limitations and Restrictions in the MATLAB Compiler documentation for details.
In addition, the MATLAB Builder JA product does not support MATLAB object data types (for example, Time Series objects). In other words, MATLAB objects can not "pass" the boundary of MATLAB/Java, but you are free to use objects in your MATLAB code.
On 64-bit Mac systems, you need to include the -d64 flag in the Java command used to run the application. This is because by default the Java Virtual Machine (JVM) starts in 32-bit client mode on these machines and the MATLAB Compiler Runtime (MCR) requires a 64-bit JVM. For example when running The Magic Square Example, you should use the following command:
matlabroot/sys/java/jre/architecture/jre_folder/bin/java -classpath :matlabroot/toolbox/javabuilder/jar/javabuilder.jar: MagicDemoJavaApp/magicsquare/distrib/magicsquare.jar -d64 getmagic 5
Since Leopard (Mac OS X 10.5), is capable of running both 32-bit and 64-bit operating systems, including the -d64 flag is only required if you are running in 64-bit mode.
Before starting to program, you must set the environment on your development machine to be compatible with the MATLAB Builder JA product.
Specify the following environment variables:
The MATLAB Builder JA product uses the JAVA_HOME variable to locate the Java Software Development Kit (SDK) on your system. It also uses this variable to set the versions of the javac.exe and jar.exe files it uses during the build process.
Setting JAVA_HOME on Windows (Development Machine). If you are working on Windows, set your JAVA_HOME variable by entering the following command in your DOS command window. (In this example, your Java SDK is installed in folder C:\java\jdk.)
set JAVA_HOME=C:\java\jdk\j2sdkversion_number
Alternatively, you can add jdk_folder/bin to the system path. For example:
set PATH=%PATH%;c:\java\jdk\j2sdkversion_number\bin
You can also set these variables globally using the Windows Control Panel. Consult your Windows documentation for instructions on setting system variables.
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 |
Setting JAVA_HOME on UNIX (Development Machine). If you are working on a UNIX system, set your JAVA_HOME variable by entering the following commands at the command prompt. (In this example, your Java SDK is installed in folder /java/jdk/j2sdkversion_number.)
setenv JAVA_HOME /java/jdk/j2sdkversion_number
Alternatively, you can add jdk_folder\bin to the system path.
To build and run a Java application that uses a MATLAB Builder JA generated component, the system needs to find .jar files containing the MATLAB libraries and the class and method definitions that you have developed and built with the builder. To tell the system how to locate the .jar files it needs, specify a classpath either in the javac command or in your system environment variables.
Java uses the CLASSPATH variable to locate user classes needed to compile or run a given Java class. The class path contains folders where all the .class and/or .jar files needed by your program reside. These .jar files contain any classes that your Java class depends on.
When you compile a Java class that uses classes contained in the com.mathworks.toolbox.javabuilder package, you need to include a file called javabuilder.jar on the Java class path. This file comes with the builder; you can find it in the following folder:
matlabroot/toolbox/javabuilder/jar % (development machine) mcrroot/toolbox/javabuilder/jar % (end-user machine)
where matlabroot refers to the root folder into which the MATLAB installer has placed the MATLAB files, and mcrroot refers to the root folder under which MCR is installed. The builder automatically includes this .jar file on the class path when it creates the component. To use a class generated by the builder, you need to add this matlabroot/toolbox/javabuilder/jar/javabuilder.jar to the class path.
In addition, you need to add to the class path the .jar file created by the builder for your compiled .class files.
Example: Setting CLASSPATH on Windows. Suppose your MATLAB libraries are installed in C:\matlabroot\runtime\win32, and your component .jar files are in C:\mycomponent.
Note For matlabroot, substitute the MATLAB root folder on your system. Type matlabroot to see this folder name. |
To set your CLASSPATH variable on your development machine, enter the following command at the DOS command prompt:
set CLASSPATH=.;C:\matlabroot\toolbox\javabuilder\jar\javabuilder.jar; C:\mycomponent\mycomponent.jar
Alternatively, if the Java SDK is installed, you can specify the class path on the Java command line as follows. When entering this command, ensure there are no spaces between path names in the matlabroot argument. For example, there should be no space between javabuilder.jar; and c:\mycomponent\mycomponent.jar in the following example:
javac -classpath .;C:\matlabroot\toolbox\javabuilder\jar\javabuilder.jar; C:\mycomponent\mycomponent.jar usemyclass.java
where usemyclass.java is the file to be compiled.
It is recommended that you globally add any frequently used class paths to the CLASSPATH system variable via the Windows Control Panel.
Example: Setting CLASSPATH on UNIX (Development Machine). Suppose your UNIX environment is as follows:
Your MATLAB libraries are installed in /matlabroot/runtime/arch, (where arch is the operating system of the machine.
Your component .jar files are in /mycomponent.
To set your CLASSPATH variable, enter the following command at the prompt:
setenv CLASSPATH .:/matlabroot/toolbox/javabuilder/jar/javabuilder.jar: /mycomponent/mycomponent.jar
Like Windows, you can specify the class path directly on the Java command line. To compile usemyclass.java, type the following:
javac -classpath .:/matlabroot/toolbox/javabuilder/jar/javabuilder.jar: /mycomponent/mycomponent.jar usemyclass.java
where usemyclass.java is the file to be compiled.
The operating system uses the native library path to locate native libraries that are needed to run your Java class. See the following list of variable names according to operating system:
| Windows | PATH |
| Linux | LD_LIBRARY_PATH |
| Macintosh | DYLD_LIBRARY_PATH |
For information on how to set these path variables, see the following topics in "Standalone Applications" of the MATLAB Compiler documentation:
See Testing the Application to set your path on a development machine
See Running the Application to set your path on an end-user machine
![]() | Reference Information for Java | Data Conversion Rules | ![]() |

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 |