Add a java.library.path to /usr/lib/jni for scala with maven and ubuntu
I'm trying to create a pom.xml which compile and run a program in scala. This project need some *.so libraries (gluegen-rt.so for example) to run. Theses files are located here : /usr/lib/jni/
I have this error when i run my program :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no gluegen-rt 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 com.jogamp.gluegen.runtime.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:102)
at com.jogamp.gluegen.runtime.NativeLibLoader.access$000(NativeLibLoader.java:51)
at com.jogamp.gluegen.runtime.NativeLibLoader$1.run(NativeLibLoader.java:70)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.gluegen.runtime.NativeLibLoader.loadGlueGenRT(NativeLibLoader.java:68)
at com.jogamp.common.jvm.JVMUtil.<clinit>(JVMUtil.java:56)
at javax.media.nativewindow.NativeWindowFactory.<clinit>(NativeWindowFactory.java:102)
at javax.media.opengl.awt.GLCanvas.<clinit>(GLCanvas.java:82)
at org.jzy3d.chart.Chart.initializeCanvas(Chart.java:65)
at org.jzy3d.chart.Chart.<init>(Chart.java:56)
at org.jzy3d.chart.Chart.<init>(Chart.java:39)
at fr.iscpif.slocalfit.testGraphique$.main(testGraphique.scala:28)
at fr.iscpif.slocalfit.testGraphique.main(testGraphique.scala)
So i make some research on linked library with maven, and i find this command line on a pom.xml :
<systemProperties>
<property>
<name>java.library.path</name>
<value>/usr/lib/jni/</value>
</property>
</systemProperties>
But i don't know where i can write this lines into my pom.xml, because i want maven add this lines to java command line before i run the main class of my program ...
Best regards, Thanks for help,
My pom.xml is actually like that :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.iscpif</groupId>
<packaging>bundle</packaging>
<artifactId>slocalfit</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${lib.org.scala-lang.scala.version}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>javax.media.opengl</groupId>
<artifactId>jogl-core</artifactId>
<version>2.0-pre-20101001</version>
</dependency>
<dependency>
<groupId>javax.media.opengl</groupId>
<artifactId>jogl-util</artifactId>
<version>2.0-pre-20101001</version>
</dependency>
<dependency>
<groupId>javax.media.nativewindow</groupId>
<artifactId>nativewindow-core</artifactId>
<version>2.0-pre-20101001</version>
</dependency>
<dependency>
<groupId>com.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<version>1.0-beta07</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.umontreal.iro</groupId>
<artifactId>ssj</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>gov.lbl.acs.colt</groupId>
<artifactId>colt</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.15</version>
</dependency>
<dependency>
<groupId>org.openmole.tools</groupId>
<artifactId>mgo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.openmole</groupId>
<artifactId>au.com.bytecode.opencsv</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>jzy3d</artifactId>
<version>0.9</version>
</dependency>
</dependencies>
<properties>
<lib.org.scala-lang.scala.version>2.9.0-1</lib.org.scala-lang.scala.version>
<maven.scala.version>${lib.org.scala-lang.scala.version}</maven.scala.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<configuration>
</configuration>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>${run.mainclass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>-->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<manifestLocation>target/META-INF</manifestLocation>
<finalName>${symbolic.name}_${project.version}</finalName>
<instructions>
<!--<Main-Class>fr.iscpif.TON.PACKAGE.TaClasse</Main-Class>-->
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*;resolution:=optional</Import-Package>
<Export-Package>fr.iscpif.slocalfit.*,org.apache.commons.math.*,org.openmole.tools.mgo.*,umontreal.iro.lecuyer.*</Export-Package>
<Embed-Dependency>*;scope=!provided;inline=true;artifactId=!scala-library</Embed-Dependency>
&开发者_StackOverflow中文版lt;Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<name>${project.artifactId} ${project.version}</name>
<repositories>
<repository>
<id>maven.iscpif.fr</id>
<name>ISCPIF repository</name>
<url>http://maven.iscpif.fr/public/</url>
</repository>
<repository>
<id>maven.iscpif.fr.snapshots</id>
<name>ISCPIF snapshots repository</name>
<url>http://maven.iscpif.fr/snapshots/</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
</repositories>
</project>
I have never worked with maven but a lot with JNI.
Have you specified the Native Library Path in the IDE that you´re using? If you use IDE like NetBeans or Eclipse you have to specify where the Java Native Library (for certain java .jar library is) is located (I mean the .dll or .so) when adding the .jar files to IDE.
For ex. in Eclipse: Right click on project -> Properties -> Java Build Path -> Libraries (on the tab bar) -> Click on the library (and expand it) and there you can find Native library location. You have only to specify the path where .so files are located. You have to do similar procedure on NetBeans: I think you have to press Project Properties -> Libraries and there you find these things.
Hope it was helpful :)
精彩评论