Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过maven为eclipse设置vm默认参数_Eclipse_Maven_Jvm Arguments_Maven Eclipse Plugin - Fatal编程技术网

通过maven为eclipse设置vm默认参数

通过maven为eclipse设置vm默认参数,eclipse,maven,jvm-arguments,maven-eclipse-plugin,Eclipse,Maven,Jvm Arguments,Maven Eclipse Plugin,我想指定-Djava.library.path=./src/main/resources的vm参数,以便自动拾取dll,我想在maven中指定此参数,以便其他开发人员不必手动配置eclipse 我在想maven eclipse插件可能会有所帮助,所以我可以做一些类似的事情 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin

我想指定-Djava.library.path=./src/main/resources的vm参数,以便自动拾取dll,我想在maven中指定此参数,以便其他开发人员不必手动配置eclipse

我在想maven eclipse插件可能会有所帮助,所以我可以做一些类似的事情

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-eclipse-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    DO MAGIC HERE ???? <<-----
  </configuration>
</plugin>

org.apache.maven.plugins
maven eclipse插件
2.7

这里有魔法吗 也许这应该是一个更一般的问题:

是否有任何方法可以在不必通过库路径指定的情况下将DLL添加到VM


我在某个地方读到过,将dll放在应用程序根目录中,并在MANIFEST.MF中使用哈希代码指定dll,会触发VM自动拾取它。但是,这可能是完全错误的。

我对您的问题的解释是,您的应用程序正在加载一个DLL,而该DLL位于您的项目的“资源”文件夹中。对吗

如果DLL位于类路径中的文件夹中,则可以获取DLL的完整路径,并使用以下方法加载它:

// assuming dll is located in the default package
URI dllUri = this.getClass().getResource("/mydll.dll").toURI();
File dllFile = new File(dllUri);
System.load(dllFile.getCanonicalPath());
这与maven无关。只有两个问题:

  • 该解决方案不是独立于系统的,因为您在getResource()的参数中指定了文件的后缀
  • 如果DLL在JAR中,这将不起作用。对于这种情况,我们构建了一个JAR提取器,它将DLL提取到一个临时文件夹中,并使用临时文件夹中的文件调用System.load()

  • 嗨,我曾经尝试过这种方法(作为Davids开发人员之一),但不幸的是,它没有成功。就好像什么也没装进去(即使装进去了)。干杯你有没有想过?
    // assuming dll is located in the default package
    URI dllUri = this.getClass().getResource("/mydll.dll").toURI();
    File dllFile = new File(dllUri);
    System.load(dllFile.getCanonicalPath());