| Contents | Index |
| On this page… |
|---|
Before Running the Hello World Example Deploying Hello World on a Computer with MATLAB, MATLAB Compiler, and MATLAB Builder JA Installed |
MATLAB Programmer
| Role | Knowledge Base | Responsibilities |
|---|---|---|
|
|
|
|
This section gives a very brief example of MATLAB Builder JA functionality. For a more extensive starter example, refer to The Magic Square Example.
Note The examples here use the Windows deploytool GUI, a graphical front-end interface to MATLAB Compiler software. For information about how to perform these tasks using the command-line interface to MATLAB Compiler software, see the mcc reference page. For information about how to start the Deployment Tool GUI from the command line, see the deploytool reference page. |
Watch a video about deploying applications using MATLAB Builder JA.
Before running this example, configure your environment. See Configuring Your Environment .
To write a function in MATLAB that displays the text hello world as output, you define the following function as hello.m.
function hello
% This is the hello, world function written in MATLAB code
% Copyright 2010 The MathWorks, Inc.
% $Revision: 1.1.6.43.2.2 $
%
fprintf(1,'Hello, World\n' );
You can find the example code for hello.m at install_root\extern\examples\compiler\hello.m.
You create a Java application by using the Deployment Tool GUI to build a Java class that wraps around the sample MATLAB code discussed in The Hello World Example.
To compile or build hello using the Deployment Tool, use the following information as you work through this example:
| Project name | helloprj |
| Class name | hellocls |
| Package name | hellopck |
| File to compile | hello.m |
Note
When a component is built, the package name is the same as the
project name, by default. To change the package name, click the
|
Start MATLAB, if you have not done so already.
Type deploytool at the command prompt, and press Enter. The Deployment Project dialog box opens.
The Deployment Project Dialog Box

Create a deployment project using the Deployment Project dialog box:
Type the name of your project in the Name field.
Enter the location of the project in the Location field. Alternately, navigate to the location.
Select the target for the deployment project from the Target drop-down menu.
Click OK.
On the Build tab:
If you are building a Java application, click Add class. Type the name of the class in the Class Name field, designated by the letter c:
![]()
For this class, add MATLAB files you want to compile by clicking Add files then click Open to select the file or files. To add another class, click Add class.
You may optionally add supporting files. For examples of these files, see the deploytool Help. To add these files, in the Shared Resources and Helper Files area:
Click Add files/directories
Click Open to select the file or files.
When you complete your changes, click the Build button
(
).
What Is a MATLAB Builder JA Project?
What Is a MATLAB Builder JA Component?
Run Hello World by entering the following from a system command shell.
Before proceeding, ensure you have renamed you package
file to hellopck. When a component is built, the
package name is the same as the project name, by default. To change
the package name, click the
Actions icon
and select Settings.
Navigate to the directory containing the JAR file.
Run the following command on:
Windows:
java -classpath
matlabroot\toolbox\javabuilder\jar\javabuilder.jar;hellopck.jar
hellopck.hellocls
UNIX:
% java -classpath
matlabroot/toolbox/javabuilder/jar/javabuilder.jar:hellopck.jar
hellopck.hellocls
where matlabroot is the location of your MATLAB installation.
Before proceeding, ensure you have renamed you package
file to hellopck. When a component is built, the
package name is the same as the project name, by default. To change
the package name, click the
Actions icon
and select Settings.
Run Hello World by entering the following from a system command shell. Ensure you are running from a directory defined to the JAVA_HOME variable. See Setting Up Your Java Environment for more information.
Windows:
java -classpath
MCRROOT\toolbox\javabuilder\jar\javabuilder.jar;hellopck.jar
hellopck.hellocls
UNIX:
% java -classpath
MCRROOT/toolbox/javabuilder/jar/javabuilder.jar:hellopck.jar
hellopck.hellocls
where MCRROOT is the location of your MCR installation
If you are running UNIX, set your system path appropriately. See Directories Required for Development and Testing and Directories Required for Run-Time Deployment.
![]() | MATLAB Builder JA Prerequisites | The Magic Square Example | ![]() |

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 |