gpt4 book ai didi

java - 让 SWI-Prolog 的 JPL 接口(interface)工作

转载 作者:行者123 更新时间:2023-11-30 10:06:38 25 4
gpt4 key购买 nike

我想使用 JPL 为我的项目创建一个图形界面,所以我去搜索了一个代码示例以开始使用,我下载了代码但是当我运行它时,它显示以下消息:

ERROR: c:/program files/swipl/library/jpl.pl:4243:
'$open_shared_object'/3: Não foi possível encontrar o módulo especificado (this stands for "it wasn't possible to find the especified module)".

ERROR: c:/program files/swipl/library/jpl.pl:4243:
c:/program files/swipl/library/jpl.pl:4243: Initialization goal raised exception:
library `java' does not exist (Please add directory holding java.dll to %PATH%)
ERROR: c:/users/User/desktop/system/medical expert system.pl:4:
Exported procedure jpl:jpl_c_lib_version/1 is not defined

当我尝试使用它显示的代码的一个功能时:

ERROR: Undefined procedure: jpl:jni_func/3
ERROR: In:
ERROR: [14] jpl:jni_func(6,'javax/swing/JFrame',_10490)
ERROR: [13] jpl:jFindClass('javax/swing/JFrame',_10522) at c:/program files/swipl/library/jpl.pl:1631
ERROR: [12] jpl:jpl_type_to_class(class([javax|...],['JFrame']),_10554) at c:/program files/swipl/library/jpl.pl:3049
ERROR: [11] jpl:jpl_new_1(class([javax|...],['JFrame']),['Expert System'],_10606) at c:/program files/swipl/library/jpl.pl:169
ERROR: [10] jpl:jpl_new('javax.swing.JFrame',['Expert System'],_10664) at c:/program files/swipl/library/jpl.pl:138
ERROR: [9] interface2 at c:/users/User/desktop/system/medical expert system.pl:180
ERROR: [7] <user>
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.

我有点想把包含 java.dll 的文件夹放到系统变量的 PATH 中,但它一直显示相同的消息我的 SWI-Prolog 是 7.6.4 64 位版本,我不认为代码本身有什么问题,因为在我下载它的视频中没有人提示它。

编辑:消息说 java.dll 现在不见了,现在只剩下 2 条其他消息,我已经在系统变量下的路径中包含了我认为相关的所有内容。

最佳答案

确保系统变量中的 CLASSPATH 变量包含与 SWI-Prolog 捆绑在一起的 jpl.jar 文件的路径。例如,在我的 Windows 7 VM 中,我从 SWI-Prolog 中获取:

?- getenv('CLASSPATH', P).
P = 'c:/program files/swipl/lib/jpl.jar'.

我使用 JPL 的所有代码在此变量定义中运行良好。此外,加载 JPL 库应该打印类似的内容(假设是最新的 SWI-Prolog 版本):

?- use_module(library(jpl)).
% Extended DLL search path with
% 'c:/Program Files/Java/jre1.8.0_201/bin/server'
% 'c:/Program Files/Java/jre1.8.0_201/bin'

更新

尝试在系统变量中定义 JAVA_HOME 变量。我在我使用的 macOS 上:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home

路径在 Windows 上会有所不同,具体取决于您安装的 Java 版本,但应以 HOME 结尾。

关于java - 让 SWI-Prolog 的 JPL 接口(interface)工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54559532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com