In order to execute a Java engine program, it depends on this "nativemvm" library. Thus, we have to tell JAVA where to find this library.
There are two approaches to do that:
1. We could directly tell JAVA the location of that library, by specifying Java Library Path and Run Program
java -Djava.library.path=matlabroot/bin/maci64 -classpath .:matlabroot/extern/engines/java/jar/engine.jar MyJavaCode
2. We could also set the environment variable, then JAVA will search all the path in the variable, until finding this library.
However, OS X EI Capitan and later includes security technology, which no longer supports the environment variable "DYLD_LIBRARY_PATH". If we print all the environment variable, "DYLD_LIBRARY_PATH" is not on the list. So if we add the path into "DYLD_LIBRARY_PATH", actually it means we just create a variable named "DYLD_LIBRARY_PATH" in current terminal, but "DYLD_LIBRARY_PATH" is not a system environment variable. So if we launch MATLAB outside this shell, for example, but clicking the icon on the desktop, or launching it in a new terminal, MATLAB will not find the environment variable "DYLD_LIBRARY_PATH" we have created in another terminal.
If you want to work by adding variable "DYLD_LIBRARY_PATH", please launch MATLAB by command line in the terminal added variable "DYLD_LIBRARY_PATH".
For more information about MAC SIP please refer to the following links: