Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - UnsatisfiedLinkError with java.library.path

I'm having a problem with trying to get Maven to load my native library. Currently, I placed my library file (.so) in src/main/resources/ and it gives me an error of it cannot be found in java.library.path. I also tried to place this in my base directory of the project, but gives me the same results.

Below is the maven plugin I tried, but it doesn't seem to work.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <systemProperties>
        <property>
          <name>java.library.path</name>
          <value>${project.build.directory}</value>
        </property>
      </systemProperties>
    </configuration>
  </plugin>

If it helps, I run my project directly from Eclipse. I know how to get it to work in Eclipse but want it to work with maven.

@EDIT I also tried running it on the command line and I still receive the same mistakes

like image 679
Hank Avatar asked Oct 24 '25 07:10

Hank


1 Answers

I did the following in my project:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
        <argLine>-Djava.library.path=/path/to/your/libs:${java.library.path}</argLine>
        </configuration>
    </plugin>
</plugins>

And it worked for me that way.

like image 174
Amr Avatar answered Oct 27 '25 01:10

Amr