One of the tests uses its own library:
System.loadLibrary("mylib");
libmylib.sois in /usr/local/lib, so I am adding this directory to the VM configuration parameters:-Djava.library.path=/usr/local/lib
However, when I run the tests with Maven, this line calls UnsatisfiedLinkError:
no mylibinjava.library.path
Java is called without this option:
/usr/lib/jvm/java-8-oracle/bin/java -Dmaven.home=/opt/idea/plugins/maven/lib/maven3 -Dclassworlds.conf=/opt/idea/plugins/maven/lib/maven3/bin/m2.conf -Didea.launcher.port=7538 -Didea.launcher.bin.path=/opt/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/idea/plugins/maven/lib/maven3/boot/plexus-classworlds-2.4.jar:/opt/idea/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=15.0.3 test
Printing System.getProperty("java.library.path")when an exception is detected gives /opt/idea/bin::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib. Apparently, the VM parameters from the startup configuration do not affect maven tasks.
So, I tried to set the library path in the VM parameters for the Maven parameters: Settings-> Build, Execution, Deployment-> Build Tools-> Maven-> Runner-> VM. This parameter affects the java call command:
/usr/lib/jvm/java-8-oracle/bin/java -Djava.library.path=/usr/local/lib -Dmaven.home=/opt/idea/plugins/maven/lib/maven3 -Dclassworlds.conf=/opt/idea/plugins/maven/lib/maven3/bin/m2.conf -Didea.launcher.port=7539 -Didea.launcher.bin.path=/opt/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/idea/plugins/maven/lib/maven3/boot/plexus-classworlds-2.4.jar:/opt/idea/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=15.0.3 test
Java , , System.getProperty("java.library.path") !
java.library.path , Maven?