Original address: http://blog.csdn.net/quqibing001/article/details/51201768
Linux Environment
System variable Ld_library_path to add Java.library.path
Windows
In the environment variable, advanced system settings, System, add the PATH variable.
Eclipse
Added in ARGUMENTS->VM Arguments, run/debug settings, properties
-Djava.library.path=/home/abc/workspace/
IntelliJ idea
Run/debug Configurations's VM options add:
-Djava.library.path=/home/abc/workspace/
Program Dynamic Add
private static void loadJNILibDynamically() { try { System.setProperty("java.library.path", System.getProperty("java.library.path") + ":/home/abc/workspace/"); Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); fieldSysPath.setAccessible(true); fieldSysPath.set(null, null);
//C++动态链接库 JNIC System.loadLibrary("JNIC"); } catch (Exception e) { // do nothing for exception }}
Different systems and programs modify the location of the Java.library.path (turn)