How can I test a component created with MATLAB Builder JA Version 2.0.3 (R2009a) within MATLAB without using a driver application?

1 view (last 30 days)
I have created a component using MATLAB Builder JA. I would like to run this component within MATLAB in order to test it without having to create a separate Java file (driver application) that instantiates the component and runs it.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 May 2010
This change has been incorporated into the documentation in Release 2010a (R2010a). For previous releases, read below for any additional information:
The following line of code will directly run a MATLAB Builder JA component that was created using the deploytool, for which the project name is "Test" and the class name is "TestClass" (note that the name of the MATLAB file included in the class is not taken into account):
- Windows:
(Note that the commands below should be executed in one line)
!java -classpath $matlabroot\toolbox\javabuilder\jar\javabuilder.jar;.\Test\distrib\Test.jar Test.TestClass
... where $MATLABROOT is the MATLAB installation directory.
Similarly, the above project can be executed on a machine that only has the MATLAB Compiler Runtime (MCR) installed:
java -classpath $matlabroot\toolbox\javabuilder\jar\javabuilder.jar;.\Test\distrib\Test.jar -Djava.library.path=$mcrroot\runtime\$ARCH Test.TestClass
... where $mcrroot is the MCR installation directory and $ARCH is the operating system and processor type of the local machine (e. g. win32).
- Linux:
(Note that the commands below should also be executed in one line)
!java -classpath $matlabroot/toolbox/javabuilder/jar/javabuilder.jar:.\Test\distrib\Test.jar Test.TestClass
Note that a colon (:) is used, instead of a semi-colon (;), to separate the class paths.
MCR:
java -classpath $matlabroot/toolbox/javabuilder/jar/javabuilder.jar:.\Test\distrib\Test.jar -Djava.library.path=$mcrroot/runtime/$ARCH Test.TestClass

More Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!