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