title: [Ant]How to add .so file into a jar and use it within jar(set the java.library.path)?
body: <p>all. I'm trying to make a <strong>bundle jar</strong> containing <a href="http://www.hyperic.com/products/sigar" rel="nofollow"><code>Sigar</code></a> library, which uses a <code>.so</code> as native support. I've zipped the <code>Sigar</code> into my.jar, when I run it from cmd, I have to type like this:</p>
  
  <pre><code>java -jar -Djava.library.path=~/path/to/lib/contains/so  my.jar
  </code></pre>
  
  <p>Yes this works, BUT I want to build a <strong>bundle jar</strong>, that, to say, contains .so into jar and use it within the jar. So my question is: <strong>how to set the java.library.path pointing to .so files within that jar</strong>. Finally, I want to make it like</p>
  
  <pre><code>java -jar my.jar (*)// hope to run it in this way
  </code></pre>
  
  <p>My <code>build.xml</code> looks like:</p>
  
  <pre><code> 27     &lt;target name="jar" depends="compile"&gt;
   28         &lt;mkdir dir="${jar.dir}"/&gt;
   29         &lt;jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"&gt;
   30             &lt;zipgroupfileset dir="${lib.dir}" includes="*.jar"/&gt;
   31             &lt;fileset dir="${lib.dir}"  includes="*.so"/&gt;
   32             &lt;fileset dir="${lib.dir}" includes="*.dylib"/&gt;
   33             &lt;manifest&gt;
   34                 &lt;attribute name="Main-Class" value="${main-class}"/&gt;
   35             &lt;/manifest&gt;
   36         &lt;/jar&gt;
   37     &lt;/target&gt;
  </code></pre>
  
  <p>By now, I just got UnsatisfiedLink Exception when I use run it in <code>(*)</code> way.</p>
  
  <p>And another relevant question is: how to add a file to a specific location in the jar. In above example, <code>&lt;fileset dir="${lib.dir}"  includes="*.so"/&gt;</code> will put *.so in the root of jar, what if I want to change this?</p>
  
  <p>Thanks in advance!</p>