Deployable Archive Embedding and Extraction

Overview

Deployable archive data is extracted from the JAR file with no separate deployable archive or packageName­mcr folder needed on the target machine. This behavior is helpful when storage space on a file system is limited.

If you don't want deployable archive data extracted by default, use either the MWComponentOptions class, or use environment variables, to specify how deployable archive data extraction and utilization is handled.

Use MWComponentOptions Class to Indicate Extraction Options

Selecting Options

Choose from the following CtfSource or ExtractLocation instantiation options to customize how to manage deployable archive content with MWComponentOptions:

  • 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 MWCtfSource:

    • MWCtfSource.NONE — Indicates that no deployable archive is to be extracted. This implies that the extracted deployable archive data is already accessible somewhere on your file system. This is a public, static, final instance of MWCtfSource.

    • MWCtfFileSource — Indicates that the deployable archive data resides within a particular file location that you specify. This class takes a java.io.File object in its constructor.

    • MWCtfDirectorySource — Indicates a folder to be scanned when instantiating the component: if a file with a .ctf suffix is found in the folder you supply, the deployable archive bits are loaded from that file. This class takes a java.io.File object in its constructor.

    • MWCtfStreamSource — Allows deployable archive bits to be read and extracted directly from a specified input stream. This class takes a java.io.InputStream object in its constructor.

  • ExtractLocation — This option specifies where the extracted deployable archive content is to be located. Since the MATLAB® Runtime requires all deployable archive content be located somewhere on your file system, use the desired ExtractLocation option, along with the component type information, to define a unique location. A value for this option is an instance of the class MWCtfExtractLocation. An instance of this class can be created by passing a java.io.File or java.lang.String into the constructor to specify the file system location to be used or one of these predefined, static final instances may be used:

    • MWCtfExtractLocation.EXTRACT_TO_CACHE — Use to indicate that the deployable archive content is to be placed in the MATLAB Runtime component cache. This is the default setting for R2007a and forward.

    • MWCtfExtractLocation.EXTRACT_TO_COMPONENT_DIR — Use when you want to locate the JAR or .class files from which the component has been loaded. If the location is found (e.g., it is on 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.

Note

Deployable archives are extracted by default to temp\user_name\mcrCachen.nn.

Setting Options

Use the following methods to get or set the location where the deployable archive may be found for an extracted component:

  • getCtfSource()

  • setCtfSource()

Use the following methods to get or set the location where the extracted deployable archive content is to be located:

  • getExtractLocation()

  • setExtractLocation()

Enabling MATLAB Runtime Component Cache, Utilizing Deployable Archive Content Already on Your System.  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 using the following statements:

MWComponentOptions options = new MWComponentOptions();

// set options for the class by calling setter methods
// on 'options'
options.setCtfSource(MWCtfSource.NONE);
  options.setExtractLocation(
    new MWCtfExtractLocation("C:\\readonlydir\\MyModel_mcr"));

// instantiate the class using the desired options 
MyModel m = new MyModel(options);

Use Environment Variables to Indicate Extraction Options

Use the following environment variables to change these settings.

Environment VariablePurposeNotes
MCR_CACHE_ROOTWhen set to the location of where you want the deployable archive to be extracted, this variable overrides the default per-user component cache location.Does not apply
MCR_CACHE_VERBOSEWhen set to any value, this variable prints logging details about the component cache for diagnostic reasons. This can be very helpful if problems are encountered during deployable archive extraction.Logging details are turned off by default (for example, when this variable has no value).
MCR_CACHE_SIZEWhen 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 mcrcachedir command, with the desired cache size limit.

Overriding Default Behavior

To extract the deployable archive, compile using the -C option when calling mcc.

You can also implement this override by entering -C in the Settings editor of the Library Compiler app.

You might want to use this option to troubleshoot problems with the deployable archive, for example, as the log and diagnostic messages are much more visible.

For More Information

For more information about the deployable archive, see Deployable Archive (MATLAB Compiler).

Was this topic helpful?