Define Embedding and Extraction Options for Deployable Java Archive
When you deploy a Java® archive, by default, the archive data is extracted from the JAR file with no
separate deployable archive or
folder needed on the
target machine. This behavior is helpful when storage space on a file system is
If you don't want to extract deployable archive data by default, you can use either the
MWComponentOptions class or environment variables to specify options
for extraction and utilization of the deployable archive data.
Extraction Options Using MWComponentOptions Class
Choose from the following
ExtractLocation instantiation options to customize how
MATLAB® Runtime manages deployable archive content with
CtfSource— This option specifies where the deployable archive may be found for an extracted component. It defines a binary data stream comprised of the bits of the deployable archive. The following values are objects of some type extending
Indicates that no deployable archive is to be extracted. This option implies that the extracted deployable archive data is already accessible somewhere in your file system. This object is a public, static, final instance of
Indicates that the deployable archive data resides within a particular file location that you specify. This class takes a
java.io.Fileobject in its constructor.
Indicates a folder to be scanned when instantiating the component. If a file with a
.ctfsuffix is found in the folder that you supply, the deployable archive bits are loaded from that file. This class takes a
java.io.Fileobject in its constructor.
Allows deployable archive bits to be read and extracted directly from a specified input stream. This class takes a
java.io.InputStreamobject in its constructor.
ExtractLocation— This option specifies where the extracted deployable archive content is to be located. Since MATLAB Runtime requires all deployable archive content be located somewhere in your file system, use the desired
ExtractLocationoption, along with the component type information, to define a unique location. A value for this option is an instance of the class
MWCtfExtractLocation. You can create an instance of this class by passing a
java.lang.Stringinto the constructor to specify the file system location to be used, or you can use one of these predefined, static final instances:
Use to indicate that the deployable archive content is to be placed in the MATLAB Runtime component cache. This option is the default setting for R2007a and forward.
Use when you want to locate the JAR or
.classfiles from where the component has been loaded. If the location is found (e.g., it is in the file system), then the deployable archive data is extracted into the same folder. This option most closely matches the behavior of R2007a and previous releases.
Deployable archives are extracted by default to
Use the following methods to get or set the location where the deployable archive may be found for an extracted component:
Use the following methods to get or set the location where the extracted deployable archive content is to be located:
Enable MATLAB Runtime Component Cache
If you want to enable the MATLAB Runtime Component Cache for a generated Java class utilizing deployable archive content already resident in your
file system, instantiate
MWComponentOptions by using the following
MWComponentOptions options = new MWComponentOptions();
// set options for the class by calling setter methods
// on 'options'
// instantiate the class using the desired options
MyModel m = new MyModel(options);
Extraction Options Using Environment Variables
Use the following environment variables to change the default settings for the cache size and location of the deployable archive extraction.
|When set to the location of where you want the deployable archive to be extracted, this
variable overrides the default per-user component cache location. This is true
.ctf files only.
|On macOS, this variable is ignored in MATLAB R2020a and later. The app bundle contains the files necessary for runtime.
|When set, this variable overrides the default component cache size.
|The initial limit for this variable is 32M (megabytes). This
may, however, be changed after you have set the variable the first
time. Edit the file
.max_size, which resides in
the file designated by running the
with the desired cache size limit.