Main Content

Locate Native Method Libraries

Java® classes can dynamically load native methods using the Java method java.lang.System.loadLibrary("LibFile"). To load the library file LibFile, the folder containing it must be on the Java Library Path. The JVM® software defines this path at startup.

You can augment the search path for native method libraries by creating an ASCII text file named javalibrarypath.txt in your preferences folder. Follow these guidelines when editing this file.

  • Create the file.

    cd(prefdir)
    edit javalibrarypath.txt
  • Specify each new folder on a line by itself.

  • Specify only the folder names, not the names of the DLL files. The System.loadLibrary call reads the file names.

  • In cross-platform environments, simplify the specification of folders by using the $matlabroot, $arch, and $jre_home macros.

You also can create a javalibrarypath.txt file in your MATLAB® startup folder. To identify the startup folder, type pwd at the command line immediately after starting MATLAB at a system prompt on Windows® or a terminal on Linux® and macOS. Libraries specified in the javalibrarypath.txt file in the startup folder override libraries specified in the file in the preferences folder.

To disable using the javalibrarypath.txt file, start MATLAB with the -nouserjavapath option.

See Also

Related Topics