Map Functions to Java Classes
Map Functions to Java Classes using Library Compiler App
The Library Compiler app provides a visual class mapper for mapping MATLAB® functions to Java® classes. The class mapper is located between the Application Information and the Additional Installer Options sections of the app.
The Namespace field at the top of the class browser specifies the name of the application into which the generated classes are placed. By default, the name of the first listed MATLAB file is used as the application name. You can change the application name to fit the naming conventions used by your organization.
The table used to match functions to classes is below the application name. The Class Name column specifies the name of the generated Java class. The Method Name column specifies the list of MATLAB functions that are mapped into methods of the generated class.
Add a New Class to a Java Application
To add a class to a Java application:
Click Add Class.
Rename the class as described in Rename a Java Class.
Add one or more methods to the class as described in Add Method to Java Class.
Rename a Java Class
To rename a Java class:
Select the name of the class to be renamed.
Open the context menu.
Select Rename.
Enter the new class name.
The class name must follow the Java naming guidelines. It cannot contain any special characters, dots, or spaces.
Delete Class from Java Application
To delete a class from a Java application:
Select the name of the class to be deleted.
Open the context menu.
Select Delete.
Add Method to Java Class
To add a method to a Java class:
In the Method Name column of the row for the class to which the method is being added, click the plus button.
Select the name of the function to add.
Delete Method from Java Class
To delete a method from a Java class:
Select the name of the function to be deleted.
Open the context menu.
Select Delete.
Tip
You can also delete the method using the Delete key.
Map Functions to Java Classes with mcc
When using mcc
to generate Java applications, you map your MATLAB functions into Java classes based on the list into which they are placed on the command
line. Class groupings are specified by adding one or more
class{
entries to the command line. All of the files not included in a class grouping are
added to the class specified by the className
:mfilename
...}-W
java:
flag.packageName
,className
For example, mcc —W java:myPackage,MyClass fun1.m fun2.m
fun3.m
generates a Java application myPackage
that contains a single class
MyClass
. MyClass
has three methods:
fun1
, fun2
, and fun3
.
However, mcc —W java:myPackage,MyClass fun1.m fun2.m
class{MyOtherClass:fun3.m}
generates a Java application myPackage
that contains two classes:
MyClass
and MyOtherClass
.
MyClass
has two methods: fun1
and
fun2
. MyOtherClass
has one method
fun3
.