Main Content

Java Example Source Code

The MATLAB® engine API for Java® ships with example code that you can use to test your environment and to become familiar with the use of the engine API. The Java source code is located in the matlabroot/extern/examples/engines/java folder, where matlabroot is the path returned by the MATLAB matlabroot command.

The folder contains these files:

  • — A Swing-based user interface that accepts an input number and uses MATLAB to calculate the factorial of the number.

  • — A Java program that uses MATLAB logical indexing and mathematical functions to operate on a numeric matrix.

  • README — A text file that describes how to build and run the examples.

To build these examples, first copy the files to a writable folder on your path. You can use the MATLAB copyfile function for this purpose:


Follow the instructions in the README file to compile and run the examples.

Related Topics