Main Content

MATLAB Runtime Run-Time Options

What Run-Time Options Can You Specify?

You can pass the options -nojvm and -logfile to MATLAB® Compiler SDK™ from a .NET client application using the assembly-level attributes NOJVM and LOGFILE. You retrieve values of these attributes by calling methods of the MWMCR class to access MATLAB Runtime attributes and state.

Getting MATLAB Runtime Option Values Using MWMCR

The MWMCR class provides several methods to get MATLAB Runtime option values. The following table lists methods supported by this class.

MWMCR MethodPurpose
MWMCR.IsMCRInitialized()Returns true if the MATLAB Runtime run-time is initialized, otherwise returns false.
MWMCR.IsMCRJVMEnabled()Returns true if the MATLAB Runtime run-time is started with .NET Virtual Machine (JVM®), otherwise returns false.
MWMCR.GetMCRLogFileName()Returns the name of the log file passed with the LOGFILE attribute.

Default MATLAB Runtime Options

If you pass no options, MATLAB Runtime starts with default option values:

MATLAB Runtime Run-Time OptionDefault Option Values
.NET Virtual Machine (JVM)NOJVM(false)
Log file usageLOGFILE(null)

These options are all write-once, read-only properties.

Use the following attributes to represent the MATLAB Runtime options you want to modify.

MWMCR AttributePurpose
NOJVMLets users start MATLAB Runtime with or without a JVM. It takes a Boolean as input. For example, NOJVM(true) starts MATLAB Runtime without a JVM.
LOGFILELets users pass the name of a log file, taking the file name as input. For example, LOGFILE("logfile3.txt").

Passing MATLAB Runtime Option Values from a C# Application.  Following is an example of how MATLAB Runtime option values are passed from a client-side C# application:

 [assembly: NOJVM(false), LOGFILE("logfile3.txt")]
    namespace App1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("In side main...");
                try
                {                
                    myclass cls = new myclass();
                    cls.hello();
                    Console.WriteLine("Done!!");
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
    }