IntelliJ Idea和JNI:确定DLL是他们需要执行的地方 [英] IntelliJ Idea and JNI: Making Sure DLL's Are Where They Need to be for Execution

查看:333
本文介绍了IntelliJ Idea和JNI:确定DLL是他们需要执行的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用项目中的第三方库,它包含两个.dll文件和一个.jar fie来提供JNI Wrapper。可以使用以下命令调用.jar文件中包含的第三方供应商的测试项目:

I am working with a third party library in a project, and it includes two .dll files and a .jar fie to provide a JNI Wrapper. The test project that the third party vendor included in the .jar file can be called using the following command:

java -cp product.jar com.company.samples.product.Test

这个工作正常,只要。 jar和两个dll都在同一个目录中。

This works just fine, as long as the .jar and both of the dll's are in the same directory.

在我的项目中,我将jar文件和dll放在同一个目录中,然后引用了jar文件作为IntelliJ Idea中的库,但这会导致库无法找到dll。有没有一种方法可以告诉Idea哪里有dll,所以它可以在执行期间将它们输出到与jar文件相同的目录中?

In my project I have placed the jar file and the dll's in the same directory, and then referenced the jar file as a library in IntelliJ Idea, but this causes the library to be unable to find the dll's. Is there a way that I can tell Idea where the dll's are so it can output them in the same directory as the jar file during execution?

推荐答案

在IntelliJ中,如果要添加 .dll 的目录,请执行以下操作:

In IntelliJ when you would like to add a directory where .dll is found do:

1)打开项目结构对话框(例如 Ctrl + Shift + Alt + S )。

1) Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).

2)在对话框的左侧窗格中,选择模块。

2) In the left-hand pane of the dialog, select Modules.

3)在右侧的窗格中,选择感兴趣的模块。

3) In the pane to the right, select the module of interest.

4)在右边在对话框的一部分,在Module页面上,选择Dependencies选项卡。

4) In the right-hand part of the dialog, on the Module page, select the Dependencies tab.

5)在Dependencies选项卡上,单击+并选择Jars或目录。

5) On the Dependencies tab, click "+" and select Jars or directories.

6)在打开的对话框中,选择必要的文件和文件夹这些可能包含此类文件的单个.class和.java文件,目录和存档(.jar和.zip)以及包含Java本机库的目录 .dll ,。so或.jnilib)。 点击确定。

6) In the dialog that opens, select the necessary files and folders. These may be individual .class and .java files, directories and archives (.jar and .zip) containing such files as well as directories with Java native libraries (.dll, .so or .jnilib). Click OK.

有关 https://www.jetbrains.com/help/idea/2016.3/configuring-module-dependencies-and-libraries.html# d1860048e28

这是我为JDBC驱动程序添加 .dll sql_auth.dll )的方法使用MS SQL的集成安全性。

This is how I add .dll (sql_auth.dll) for JDBC driver to use integrated security of MS SQL.

这篇关于IntelliJ Idea和JNI:确定DLL是他们需要执行的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆