启用S​​WI-Prolog的JPL界面

时间:2019-02-06 17:39:13

标签: java prolog swi-prolog jpl

我想使用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条消息了,我已经在系统变量下的路径中添加了我认为与它相关的所有内容。

1 个答案:

答案 0 :(得分:1)

确保“系统变量”中的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结尾。

相关问题