2011-08-01 75 views
1

我試圖創建一個pom.xml,它可以在scala中編譯和運行一個程序。 該項目需要一些* .so庫(例如gluegen-rt.so)來運行。論文文件所在的位置:/ usr/lib中/ JNI/將java.library.path添加到/ usr/lib/jni for scala使用maven和ubuntu

我有這樣的錯誤,當我運行我的程序:

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) 

所以我就與Maven鏈接庫的一些研究,我發現這個命令在一個pom.xml行:

<systemProperties> 
<property> 
<name>java.library.path</name> 
<value>/usr/lib/jni/</value> 
</property> 
</systemProperties> 

但我不知道在那裏我可以寫此行到我的pom.xml,因爲我想行家我跑之前添加此行java命令行馬在課堂上我的節目...

最好的問候, 感謝您的幫助,

我的pom.xml實際上是這樣的:

<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> 
         <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> 

回答

0

我從來沒有使用Maven,但很多合作過的JNI。

您是否在IDE中指定了您使用的本機庫路徑? 如果您使用IDE(如NetBeans或Eclipse),則必須指定在將IDE文件添加到IDE中時,Java Native Library(對於某些java .jar庫)所在的位置(我的意思是.dll或.so)。

例如,在Eclipse中:右鍵單擊項目 - >屬性 - > Java構建路徑 - >庫(在選項卡欄上) - >單擊庫(並展開它),然後您可以找到本機庫位置。您只需指定.so文件所在的路徑。 您必須對NetBeans執行類似的過程:我認爲您必須按項目屬性 - >庫並在那裏找到這些東西。

希望它有幫助:)