Java Package Compiler
Description
The Java Package Compiler packages MATLAB® programs into Java® packages that you can integrate into Java applications. The interactive menus and dialog boxes used in the compiler
apps build compiler.build commands that are customized to your
specification.
Compiler app advantages include:
You can perform deployment tasks with a single intuitive interface.
You can organize your files in a MATLAB project.
Your project state persists between sessions.
You can load previously stored compiler tasks from a prepopulated menu.
You can package applications with an installer for distribution.
For more information, see Target-Specific Compiler Apps for MATLAB Code Deployment.
Open the Java Package Compiler App
MATLAB toolstrip: On the Apps tab, under Application Deployment, click the app icon.
MATLAB command prompt: Enter
javaPackageCompiler.
Parameters
Exported Functions
Files implementing MATLAB functions. Files must have one of the following extensions:
.m, .p, .mlx, or
.mexa64.
All files must be located in the project root folder to be added to the
project. To add MATLAB functions to the deployable archive., click Add Exported
Function and select your MATLAB file. In the Project panel, the file you selected gains the labels
Design and Exported Function File.
Package Info
Name of the generated Java package.
Version number of the package.
Name of application author.
Email address of the application author.
Name of company that created the application.
Summary description of the package, specified as a character vector or a string scalar.
Detailed description of the package, specified as a character vector or a string scalar.
Output Locations
Path to folder where the build artifacts are generated.
Path to folder where the installer is generated.
If you enable this property, then debugging symbol information is included in the compiled artifact. This option also causes
mbuildto pass appropriate debugging flags to the system compiler. The debug option lets you back trace up to the point where you can identify if the failure occurred in the initialization of MATLAB Runtime, the function call, or the termination routine. This option does not let you debug your MATLAB files with an external debugger.If you disable this property, then debug symbols are not included. This is the default option.
Build Settings
Name of the Java class. Class names must meet Java class name requirements.
The default value is Class1.
Obfuscate folder structures, file names, and user code in the deployable archive.
If you enable this property, then folder structures and file names in the
deployable archive are obfuscated from the end user, and user code and data
contained in .m, .mlapp,
.p, .mat, MLX, SFX, and MEX files are
placed into a user package within the archive. Additionally, all
.m files are converted to P-files before packaging.
During runtime, MATLAB code and data is decrypted and loaded directly from the user package rather than extracted to the file system. MEX files are temporarily extracted from the user package before being loaded.
To manually include additional file types in the user package, add each file
type in a separate extension tag to the file
.matlabroot/toolbox/compiler/advanced_package_supported_files.xml
The following are not supported:
verfunctionCalling external libraries such as DLLs
Out-of-process MATLAB Runtime (C++ shared library for MATLAB Data Array)
Out-of-process MEX file execution (
mexhost,feval,matlab.mex.MexHost)Before R2023b:
.matfiles other than v7.3
Enabling this option is equivalent to using mcc with
-j and -s specified.
If you do not enable this property, then the deployable archive is not obfuscated. This is the default behavior.
Files Required for Package to Run
Support packages to include in the deployable archive. The dependency analysis
process detects and includes the required support packages automatically. Only the
specified support packages are included. To list installed support packages or
those used by a specific file, see compiler.codetools.deployableSupportPackages.
Additional files and folders to include in the deployable archive. To add the contents of a folder, click Add Folder. To add an individual file, click Add File.
Additional files to include in the deployable archive. The dependency analysis process detects and includes required data files automatically unless Automatically include data files that are provided as inputs to functions such as load and fopen is disabled.
To view the file analysis results, click View Analysis. To perform the dependency analysis process again, click Reanalyze.
Automatically include data files in the deployable archive.
If you enable this property, then data files that you provide as inputs to certain functions (such as
loadandfopen) are automatically included in the deployable archive. This is the default option.If you disable this property, then you must add data files to the package in the Custom Requirements section.
Samples
Generate and modify sample MATLAB files, which are compiled into Java code that demonstrates how to call a MATLAB exported function in the target language.
For each MATLAB sample file you include during packaging, a sample application in
the target language is generated in a folder named samples.
These samples are also included in the installer.
To upload a MATLAB script you have already written, click Add existing sample.
To generate a new MATLAB sample file, click Create new sample. This opens up a MATLAB script for you to edit. After packaging, the generated sample code calls your exported function using the same arguments as in the sample MATLAB script.
For more information, see Create Sample Code to Call Exported Function.
Java API Selection
In the Java API Selection section, choose the API to use for exchanging data between the Java application and the MATLAB functions.
Create interface that uses the MATLAB Data API for Java
Create interface that uses the mwArray API for Java
Choosing a Java deployment option comes down to understanding the capabilities of
each option and recognizing how those capabilities line up with your development
requirements. Both options provide a comprehensive set of APIs for handling both
application management and data manipulation. MathWorks® recommends using the more modern MATLAB Data API over the mwArray API.
Installer Details
MATLAB Runtime delivery option, specified as one of the following.
Fetch MATLAB Runtime from mathworks.com during application installation — Option for the installer to download MATLAB Runtime from the MathWorks website during application installation. This option is the default behavior.
Include MATLAB Runtime in application installer for offline installation — Option to include MATLAB Runtime within the installer so that it can be installed during application installation without connecting to the MathWorks website. Use this option if you think your end user might not have access to the internet.
Do not include MATLAB Runtime in application installer — Option to not install MATLAB Runtime during application installation. Use this option if you think your end user will install MATLAB Runtime using another method. (since R2024a)
Note
If you use either the Fetch or Include option, the full MATLAB Runtime will be installed. To create a minimal MATLAB Runtime installer that can run one or more specific MATLAB Runtime applications, see compiler.runtime.customInstaller. (since R2024b)
Name of the generated installer.
Path to folder where the application will be installed. The folder is located in the %ProgramFiles% folder of the target machine.
Notes about additional requirements for using the application.
Image file used as the installer splash screen, specified as a character vector or a string scalar. The splash screen icon will be resized to 400 pixels by 400 pixels.
Image file used as the icon for the installer.
Image file used as the installer logo, specified as a character vector or a string scalar. The logo will be resized to 112 pixels by 290 pixels.
Version History
Introduced in R2025aSince R2025a, use compiler.build.javaPackage or mcc to map MATLAB functions to Java classes.
In R2024b and earlier releases, you can generate Java packages using the Library Compiler. Starting in R2025a, use the Java Package Compiler to create Java packages.
In R2024b and earlier releases, the compiler apps generate output files in the
folders for redistribution, for
redistribution_files_only, and for testing. Starting in
R2025a, the compiler apps generate output files in a folder named after the compiler
task.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)