How To Set Java Library Path System Property Mac

2014-11-28  最近在做一个项目的过程中需要用到第三方的jar包和动态链接库(dll),其中jar包可以直接引入,问题是在开发的时候dll可以放在System32下, 但是当项目完成后build的时候,这种方式就行不通了,所以必须考虑其他的方式来引用所需的dll文件。. Advanced configuration. Besides the standard options available in the Settings/Preferences dialog Ctrl+Alt+S, IntelliJ IDEA enables you to perform low-level configuration of the underlying platform and the Java runtime. This may lead to unexpected problems and make your IntelliJ IDEA installation inoperable if you are not sure what you are doing.

The java.lang.System.setProperty method will not work as the java.library.path variable is read during JVM start up (MATLAB start up) only.
There are several options to allow the MATLAB JVM to find a library.
1. Add the directory that contains the library to the following file:
where 'matlabroot' is the MATLAB installation directory. MATLAB uses this file to set its JVM Java library path on start up. Each path entry must be on a new line in the file. MATLAB must be restarted after editing the file as it is only read during start up. Admin privileges may be necessary.
Alternatively, this file may be placed in the MATLAB start up directory, but this is not recommended. Having more than one librarypath.txt file per MATLAB installation is not recommended.
2. Preload the desired library using the MATLAB built-in Java interface. Once it is loaded into the JVM memory, the JVM should be able to utilize it without needing to find it on the library path. Use the following command in the MATLAB command window to preload:
Java
java.lang.System.load('C:librariesmylib.dll');%Windows
java.lang.System.load('/Users/username/libraries/libMylib.so');%Unix
While this method does not require admin privileges and does not require MATLAB restart, the changes are not persistent and you will need to reload the library after every MATLAB start up.
3. Place the desired library in the same folder as the MATLAB executable:
where 'matlabroot' is the MATLAB installation directory and 'arch' is the architecture (win64, glnxa64, etc.). This directory is always on the Java library path so any library placed here will always be visible to the JVM.
The Java library path is initialized using the PATH (on Windows) and LD_LIBRARY_PATH (on Linux, UNIX) environment variables. Set these variables to include the directory that holds the desired library, and then restart MATLAB. This may require admin privileges.

Since OS X 10.7 Java is not (pre-)installed anymore, let’s fix that. As I’m writing this, Java 11.0.4 is the latest version and AdoptOpenJDK is one of the best places to find Prebuilt OpenJDK Binaries. Easy to follow details about how to install OpenJDK are available here.

However, the easiest way is to select OpenJDK 11 (LTS), the HotSpot JVM, and macOS x64, which will expose two option like these:
Clicking on “Install JDK installer”, will download the OpenJDK installer package, e.g. OpenJDK11U-jdk_x64_mac_hotspot_11.0.4_11.pkg, which when executed, will install into this location: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk

Almost done. After opening a terminal, the successful installation of the JDK can be confirmed like so:

How To Set Java Library Path System Property Mac Pro

… hopefully showing something like this:

2
4
6
openjdk11.0.42019-07-16
OpenJDK Runtime Environment AdoptOpenJDK(build11.0.4+11)
OpenJDK64-Bit Server VM AdoptOpenJDK(build11.0.4+11,mixed mode)
echo$JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

Source Code

The source code of the Java Platform, Standard Edition 11 Reference Implementations binaries is available under the GPLv2 in a single zip file.

API Specification

The API Specification of the Java Platform, Standard Edition and Java Development Kit
can be found here: https://docs.oracle.com/en/java/javase/11/docs/api/
.