我正在尝试创建一个在scala中编译和运行程序的pom.xml。 该项目需要运行一些* .so库(例如gluegen-rt.so)。这些文件位于:/ usr / lib / jni /
运行程序时出现此错误:
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中,因为我想要maven将这些行添加到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 :(得分:0)
我从未与maven合作,但与JNI合作很多。
您是否在IDE中指定了本机库路径? 如果您使用像NetBeans或Eclipse这样的IDE,那么在将.jar文件添加到IDE时,您必须指定Java Native Library(对于某些java .jar库)所在的位置(我的意思是.dll或.so)。
对于前。在Eclipse中:右键单击项目 - &gt;属性 - &gt; Java构建路径 - &gt;库(在标签栏上) - &gt;单击库(并展开它),您可以在那里找到本机库位置。您只需指定.so文件所在的路径。 您必须在NetBeans上执行类似的过程:我认为您必须按Project Properties - &gt;图书馆,你找到这些东西。
希望它有用:)