首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SWI-Prolog的JPL接口

使用SWI-Prolog的JPL接口
EN

Stack Overflow用户
提问于 2019-02-07 01:39:13
回答 1查看 538关注 0票数 2

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

代码语言:javascript
复制
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

当我尝试使用代码的一个函数时,它会显示:

代码语言:javascript
复制
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的文件夹放到系统变量的路径中,但它一直显示相同的信息我的SWI-Prolog是7.6.4 64位,我不认为代码本身有任何问题,因为在我下载它的视频中没有人抱怨它。

编辑:这条消息说java.dll现在已经消失了,现在只剩下另外两条消息了,我已经在系统变量下的Path中包含了我认为相关的所有内容。

EN

回答 1

Stack Overflow用户

发布于 2019-02-07 03:18:41

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

代码语言:javascript
复制
?- getenv('CLASSPATH', P).
P = 'c:/program files/swipl/lib/jpl.jar'.

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

代码语言:javascript
复制
?- 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上使用:

代码语言:javascript
复制
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54559532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档