java JPL/SWI Prolog 配置失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12283471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JPL/SWI Prolog configuration failure
提问by user1649263
I'm configuring the JPL right now, and wanna work with swi-prolog using java.
我现在正在配置 JPL,并想使用 java 使用 swi-prolog。
I downloaded the newest stable version of SWI-Prolog, which is 6.2.0, and installed in D:\swipl
我下载了最新的稳定版SWI-Prolog 6.2.0,安装在D:\swipl
First, I added the following path to the PATH virable: D:\swipl\bin, which should include all dll files needed.
首先,我将以下路径添加到 PATH virable:D:\swipl\bin,它应该包括所有需要的 dll 文件。
Then, I added the following path to the CLASSPATH virable: D:swipl\lib\jpl.jar, which should be the jar file needed.
然后,我将以下路径添加到 CLASSPATH virable:D:swipl\lib\jpl.jar,这应该是所需的 jar 文件。
When I tried to run the versions example provided, I got the following error:
当我尝试运行提供的版本示例时,出现以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
at jpl.fli.Prolog.thread_self(Native Method)
at jpl.Query.open(Query.java:286)
at jpl.Util.textToTerm(Util.java:162)
at jpl.Query.Query1(Query.java:183)
at jpl.Query.<init>(Query.java:176)
at Versions.main(Versions.java:11)
After searching online, I found that many people just get java.lang.UnsatisfiedLinkError: no jpl in java.library.path
which is because of the setting for the PATH
variable, rather than the error I get here: java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
(and yes, there is a "I" at the end of the line).
在网上搜索后,我发现很多人只是java.lang.UnsatisfiedLinkError: no jpl in java.library.path
因为PATH
变量的设置,而不是我在这里得到的错误:(java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
是的,行尾有一个“I”)。
Has anyone gotten this error before? I've tried several previous version of SWI-Prolog, but also got other kinds of errors. I'm using Eclipse IDE for Java development -- have I missed anything?
以前有人遇到过这个错误吗?我已经尝试了几个以前版本的 SWI-Prolog,但也遇到了其他类型的错误。我正在使用 Eclipse IDE 进行 Java 开发——我错过了什么吗?
回答by user1649263
I've sent the problem to the official mailing list ([email protected]) provided by swi-prolog.org, and luckily someone helped me to prove that there are some problems in the version 6.2.0. We then both tried the version 6.0.2, and it works perfectly. He mentioned that (and I noticed that) there is no swipl.dll in the bin folder of the version 6.2.0, which MAY causes the issue.
我已经把问题发到swi-prolog.org提供的官方邮件列表([email protected]),幸好有人帮我证明6.2版本有问题.0。然后我们都尝试了 6.0.2 版本,它运行良好。他提到(我注意到)版本 6.2.0 的 bin 文件夹中没有 swipl.dll,这可能会导致问题。
I've already reported the issue to the staff via Email, and at least for now, I suggest that people who want to configure JPL should download the version 6.0.2. Three things to remember:
我已经通过电子邮件向工作人员报告了这个问题,至少现在,我建议想要配置JPL的人应该下载6.0.2版本。要记住的三件事:
add a new variable SWI_HOME_DIR under system variables in environment variables, and set the path to the place where you installed the SWI-Prolog (Mine is D:\swipl);
Add the path %SWI_HOME_DIR%\bin to your PATH variable, rather than use something like "D:\swipl\bin". (Otherwise [FATAL ERROR: Could not find system resources] will occur)
Add the path %SWI_HOME_DIR%\lib\jpl.jar to your PATH variable, rather than use something like "D:\swipl\lib\jpl.jar". (Otherwise [FATAL ERROR: Could not find system resources] will occur)
在环境变量中的系统变量下添加一个新的变量SWI_HOME_DIR,并将路径设置为你安装SWI-Prolog的地方(我的是D:\swipl);
将路径 %SWI_HOME_DIR%\bin 添加到您的 PATH 变量中,而不是使用诸如“D:\swipl\bin”之类的内容。(否则会出现【致命错误:找不到系统资源】)
将路径 %SWI_HOME_DIR%\lib\jpl.jar 添加到您的 PATH 变量中,而不是使用类似“D:\swipl\lib\jpl.jar”的内容。(否则会出现【致命错误:找不到系统资源】)
If you are using Eclipse for Java development, it seems that you DO NOT need to configure in your IDE. As long as you follow the 3 steps above and add the correct jar file as an external library, it should be fine.
如果您使用 Eclipse 进行 Java 开发,似乎不需要在您的 IDE 中进行配置。只要按照上面的3个步骤,把正确的jar文件添加为外部库,应该就可以了。
I'm not sure whether the temporary solution works for everyone, but definitely, everyone who has the issue should try this method first. As long as the issue in the version 6.2.0 has been figured out, I'll add some comments here.
我不确定临时解决方案是否适用于每个人,但肯定的是,每个遇到问题的人都应该先尝试这种方法。等6.2.0版本的问题解决了,我会在这里补充一些意见。
BTW, as far as I know, until now, people who have the issue are using 32-bit Windows.
顺便说一句,据我所知,到目前为止,遇到问题的人都在使用 32 位 Windows。
回答by knownasilya
Try adding your path to java.library.path via Run > Run Configuration > [project name] and add the following under "VM Arguments" tab.
尝试通过 Run > Run Configuration > [project name] 将您的路径添加到 java.library.path 并在“VM Arguments”选项卡下添加以下内容。
-Djava.library.path="D:\swipl\bin;."
Furthermore, under the "Environment" tab, add the following:
此外,在“环境”选项卡下,添加以下内容:
VARIABLE: PATH
VALUE: D:\swipl\bin;${env_var:PATH}
After that, go to Project > Properties > Java Build Path, select "Libraries" tab.
Click "Add External JARS.." and find your jpl.jar
.
之后,转到 Project > Properties > Java Build Path,选择“Libraries”选项卡。单击“添加外部 JARS..”并找到您的jpl.jar
.
回答by rivax
Great Great Great, second answer is the solution
太好了,太棒了,第二个答案是解决方案
- create SWI_HOME_DIR variable to set the swi prolog instalation directory SWI_HOME_DIR ------- C:\Program Files\swipl
- set PATH to point to the library and bin like this PATH ------ %SWI_HOME_DIR%\bin;%SWI_HOME_DIR%\lib\jpl.jar
- 创建 SWI_HOME_DIR 变量来设置 swi prolog 安装目录 SWI_HOME_DIR ------- C:\Program Files\swipl
- 将 PATH 设置为指向库和 bin 像这样 PATH ------ %SWI_HOME_DIR%\bin;%SWI_HOME_DIR%\lib\jpl.jar
This fix my problem "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path windows" it is a little bit rare but it works find.
这解决了我的问题“线程“main”中的异常java.lang.UnsatisfiedLinkError:java.library.path windows中没有jpl”它有点罕见但它可以找到。
回答by Wellmor
I had the same problem. In addition to set the PATH, you need to verify if the installed SWI program has the same architecture (32 or 64) of your JVM.
我有同样的问题。除了设置 PATH 之外,您还需要验证安装的 SWI 程序是否与您的 JVM 具有相同的架构(32 位或 64 位)。