Main Content

Set MATLAB Runtime Path for Run-Time Deployment

After you install MATLAB® Runtime, add the run-time directories to the system library path according to the instructions for your operating system and shell environment.

Note

  • Ensure that the MATLAB Runtime directories are not already present in the path before adding them.

  • Save the value of your current library path as a backup before modifying it.

  • Your library path may contain multiple versions of MATLAB Runtime. Applications launched without using the shell script use the first version listed in the path.

Path for Java Applications on All Platforms

When you run Java® applications that contain compiled MATLAB code, you must set the path so that the system can find MATLAB Runtime.

When you deploy a Java application to end users, they must set the class path on the target machine. For their system to locate the .jar files containing the MATLAB libraries, users must specify a classpath either in the javac command or in their system environment variables. For more information, see Configure Your Java Environment (MATLAB Compiler SDK).

Path Modifications Required for Accessibility

In order to use some screen-readers or assistive technologies, such as JAWS®, you must add the following DLLs to your Windows® path:

matlabroot\sys\java\jre\arch\jre\bin\JavaAccessBridge.dll
matlabroot\sys\java\jre\arch\jre\bin\WindowsAccessBridge.dll
You may not be able to use such technologies without doing so.

Windows

The MATLAB Runtime installer for Windows automatically sets the library path during installation. If you do not use the installer, complete the following steps to set the PATH environment variable permanently.

Graphical Approach

  1. Run C:\Windows\System32\SystemPropertiesAdvanced.exe and click the Environment Variables... button.

  2. Select the system variable Path and click Edit....

    Note

    If you do not have administrator rights on the machine, select the user variable Path instead of the system variable.

  3. Click New and add the directory <MATLAB_RUNTIME_INSTALL_DIR>\runtime\<arch>. For example, if you are using MATLAB Runtime R2021a located in the default installation directory on 64-bit Windows, add C:\Program Files\MATLAB\MATLAB Runtime\v910\runtime\win64.

  4. Click OK to apply the change.

Command-Line Approach Using PowerShell

  1. Execute the following command using Windows PowerShell with elevated privileges to save the current system path as a variable named mypath and display it in the console.

    ($mypath = (Get-Item "HKLM:\System\CurrentControlSet\Control\Session Manager\Environment").GetValue("PATH", $null, "DoNotExpandEnvironmentNames"))

  2. Append your MATLAB Runtime directory to the mypath variable. If there is a semicolon at the end of your current path or the path is empty, then delete the semicolon from the following command.

    $mypath = "${mypath};<MATLAB_RUNTIME_INSTALL_DIR>\runtime\<arch>"

    For example, if you are using MATLAB Runtime R2021a located in the default installation directory on 64-bit Windows, use the following command:

    $mypath = "${mypath};C:\Program Files\MATLAB\MATLAB Runtime\v910\runtime\win64"

  3. Display the value of mypath to ensure the path is correct.

    echo %mypath%

  4. Set the system path to the value of mypath.

    Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $mypath

  5. Sign out of Windows to apply the change.

Linux

In the terminal, display the SHELL variable to determine your current shell environment.

echo $SHELL
For information on setting environment variables in shells other than Bash, see your shell documentation.

Bash Shell

  1. Save your current library path as a variable named mypath and display it in the console.

    mypath=$LD_LIBRARY_PATH && echo $mypath

  2. Append the MATLAB Runtime directories to the mypath variable. The following command must be entered as a single line.

    mypath="${mypath:+${mypath}:}
    <MATLAB_RUNTIME_INSTALL_DIR>/runtime/glnxa64:
    <MATLAB_RUNTIME_INSTALL_DIR>/bin/glnxa64:
    <MATLAB_RUNTIME_INSTALL_DIR>/sys/os/glnxa64:
    <MATLAB_RUNTIME_INSTALL_DIR>/extern/bin/glnxa64"

    Note

    If you are using OpenGL®, replace /extern/bin/glnxa64 with /sys/opengl/lib/glnxa64.

    For example, if you are using MATLAB Runtime R2021a located in the default installation directory, use the following command entered on a single line:

    mypath="${mypath:+${mypath}:}/usr/local/MATLAB/MATLAB_Runtime/v910/runtime/glnxa64:
    /usr/local/MATLAB/MATLAB_Runtime/v910/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v910/extern/bin/glnxa64"

  3. Display the value of mypath to ensure the path is correct.

    echo $mypath

  4. Set the LD_LIBRARY_PATH variable for the current session.

    export LD_LIBRARY_PATH=$mypath

  5. To set the variable permanently, append the export command to a file in your home directory named .bashrc.

    echo "export LD_LIBRARY_PATH=$mypath" >> ~/.bashrc

  6. Type ldd --version to check your version of GNU® C library (glibc). If the version displayed is 2.17 or lower, add <MATLAB_RUNTIME_INSTALL_DIR>/bin/glnxa64/glibc-2.17_shim.so to the LD_PRELOAD environment variable.

  7. To apply changes to the current session, type source ~/.bashrc.

macOS

In the terminal, display the SHELL variable to determine your current shell environment.

echo $SHELL

Zsh Shell (macOS Catalina 10.15 or Later)

  1. Save your current library path as a variable named mypath and display it in the console.

    mypath=$DYLD_LIBRARY_PATH && echo $mypath

  2. Append the MATLAB Runtime directories to the mypath variable. The following command must be entered as a single line.

    mypath="${mypath:+${mypath}:}
    <MATLAB_RUNTIME_INSTALL_DIR>/runtime/maci64:
    <MATLAB_RUNTIME_INSTALL_DIR>/bin/maci64:
    <MATLAB_RUNTIME_INSTALL_DIR>/sys/os/maci64"

    For example, if you are using MATLAB Runtime R2021a located in the default installation directory, use the following command entered on a single line:

    mypath="${mypath:+${mypath}:}/Applications/MATLAB/MATLAB_Runtime/v910/runtime/maci64:
    /Applications/MATLAB/MATLAB_Runtime/v910/bin/maci64:/Applications/MATLAB/MATLAB_Runtime/v910/sys/os/maci64"

  3. Display the value of mypath to ensure the path is correct.

    echo $mypath

  4. Set the DYLD_LIBRARY_PATH variable for the current session.

    setenv DYLD_LIBRARY_PATH $mypath

  5. To set the variable permanently, append the setenv command to a file in your home directory named .zshrc.

    echo "setenv DYLD_LIBRARY_PATH $mypath" >> ~/.zshrc

  6. To apply changes to the current session, type source ~/.zshrc.

Bash Shell (macOS Mojave 10.14 or Earlier)

  1. Save your current library path as a variable named mypath and display it in the console.

    mypath=$DYLD_LIBRARY_PATH && echo $mypath

  2. Append the MATLAB Runtime directories to the mypath variable. The following command must be entered as a single line.

    mypath="${mypath:+${mypath}:}
    <MATLAB_RUNTIME_INSTALL_DIR>/runtime/maci64:
    <MATLAB_RUNTIME_INSTALL_DIR>/bin/maci64:
    <MATLAB_RUNTIME_INSTALL_DIR>/sys/os/maci64"

    For example, if you are using MATLAB Runtime R2021a located in the default installation directory, use the following command entered as a single line:

    mypath="${mypath:+${mypath}:}/Applications/MATLAB/MATLAB_Runtime/v910/runtime/maci64
    :/Applications/MATLAB/MATLAB_Runtime/v910/bin/maci64:/Applications/MATLAB/MATLAB_Runtime/v910/sys/os/maci64

  3. Display the value of $mypath to ensure the path is correct.

    echo $mypath

  4. Set the DYLD_LIBRARY_PATH variable for the current session.

    export DYLD_LIBRARY_PATH=$mypath

  5. To set the variable permanently, append the export command to a file in your home directory named .profile.

    echo "export DYLD_LIBRARY_PATH=$mypath" >> ~/.profile

  6. To apply changes to the current session, type source ~/.profile.

Related Topics