Main Content

MathWorks.MATLAB.Runtime.NojvmAttribute

.NET attribute class that launches MATLAB Runtime without Java Virtual Machine (JVM) support

Since R2022b

Description

The Nojvm attribute lets you launchMATLAB® Runtime without Java® Virtual Machine (JVM®) support.

Assemblies

C:\Program Files\MATLAB\R2024b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Runtime.dll

C:\Program Files\MATLAB\R2024b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Types.dll

Class Details

Namespace:

MathWorks.MATLAB.Runtime
Superclass:System.Attribute

Construction

[assembly: Nojvm(tf)] launches MATLAB Runtime without Java Virtual Machine (JVM) support if tf is set to true. If tf is set to false, MATLAB Runtime is launched with JVM support.

Parameters

tf

Boolean true or false.

C# Example

using System;
using MathWorks.MATLAB.Runtime;
using MathWorks.MATLAB.Types;
[assembly: Nojvm(true)]

namespace MyConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string ctfPath = @"P:\MATLAB\work\mylinspace.ctf ";
                using (dynamic matlab = MATLABRuntime.StartMATLAB(ctfPath))
                {
                    double[] vec = matlab.mylinspace(1.0, 100.0);
                    foreach (double i in vec)
                    {
                        Console.Write("{0} ", i);
                    }
                }
            }
            catch (MathWorks.MATLAB.Exceptions.MATLABNotAvailableException)
            {
                Console.Error.WriteLine("Could not start MATLAB Runtime.");
            }
            MATLABRuntime.TerminateApplication();
        }
    }
}

Version History

Introduced in R2022b