title: How to include native library on maven's java.library.path variable
body: <p>I am trying to use JNotify for my application , which has the following requirements</p>
  <blockquote>
  <p>JNotify can be tested by simply running the jar file with the followng commend:
  java -Djava.library.path=. -jar jnotify-VER.jar [dir]</p>
  <p>JNotify will then monitor the specified dir (or the current directory if dir is not specified) and print detected events. Note that <b>java.library.path</b> should point to the <b>location of the native libraries</b> that comes with jnotify (dlls, so dylibs etc).</p>
  </blockquote>
  <p>But trying to get the same thing working with maven is not working out. I am trying to run a simple test but I get the following error</p>
  <pre><code>    java.lang.UnsatisfiedLinkError: no jnotify in java.library.path
      at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
      at java.lang.Runtime.loadLibrary0(Runtime.java:823)
      at java.lang.System.loadLibrary(System.java:1028)
      at net.contentobjects.jnotify.linux.JNotify_linux.&lt;clinit&gt;(Unknown Source)
      at net.contentobjects.jnotify.linux.JNotifyAdapterLinux.&lt;init&gt;(Unknown Source)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)        
  </code></pre>
  <p>which means the native files are not found on the library path.</p>
  <p>My pom.xml looks like this -</p>
  <p>I have added the jar and .so to our internal repository</p>
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;net.contentobjects&lt;/groupId&gt;
              &lt;artifactId&gt;jnotify&lt;/artifactId&gt;
              &lt;version&gt;0.93&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
             &lt;groupId&gt;net.contentobjects&lt;/groupId&gt;
             &lt;artifactId&gt;jnotify&lt;/artifactId&gt;
             &lt;version&gt;0.93&lt;/version&gt;
             &lt;type&gt;so&lt;/type&gt;
  &lt;/dependency&gt;
  
  
  &lt;plugin&gt;
       &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
       &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
       &lt;configuration&gt;
              &lt;argLine&gt;-Djava.library.path=target/lib/&lt;/argLine&gt;
       &lt;/configuration&gt;
  &lt;/plugin&gt;
  
  &lt;plugin&gt;
       &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
       &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
       &lt;executions&gt;
         &lt;execution&gt;
                &lt;id&gt;copy&lt;/id&gt;
                &lt;phase&gt;compile&lt;/phase&gt;
                &lt;goals&gt;
                       &lt;goal&gt;copy&lt;/goal&gt;
                &lt;/goals&gt;
                &lt;configuration&gt;
                      &lt;artifactItems&gt;
                        &lt;artifactItem&gt;
                               &lt;groupId&gt;net.contentobjects&lt;/groupId&gt;
                               &lt;artifactId&gt;jnotify&lt;/artifactId&gt;
                               &lt;version&gt;0.93&lt;/version&gt;
                               &lt;type&gt;so&lt;/type&gt;
                               &lt;overWrite&gt;true&lt;/overWrite&gt;
                        &lt;outputDirectory&gt;${project.build.directory}/lib&lt;/outputDirectory&gt;
                       &lt;/artifactItem&gt;
                       &lt;/artifactItems&gt;
                 &lt;/configuration&gt;
               &lt;/execution&gt;
            &lt;/executions&gt;
   &lt;/plugin&gt;
  </code></pre>
  <p>This doesn't work though, any ideas whats missing?</p>
  <p>thanks</p>