The Library Compiler app presents 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 package into which the generated classes are placed. By default, the name of the first listed MATLAB file is used as the package name. You can change the package name to fit the naming conventions used by your organization.
The table used to match functions to classes is below the package 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.
To add a class to a Java package:
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 a Method to 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.
To delete a class from a Java package:
Select the name of the class to be deleted.
Open the context menu.
Select Delete.
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.
To delete a method from a Java class:
Select the name of the function to be deleted.
Open the context menu.
Select Delete.
You can also delete the method using the Delete key.
When using mcc
to
generate Java packages, 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 specifically 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 package 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 package myPackage
that
contains two classes: MyClass
and MyOtherClass
. MyClass
has
two methods: fun1
and fun2
. MyOtherClass
has
one method fun3
.