I want to use JPL to create a graphic interface to my project, so I went and searched a code example to start working with, I downloaded the code but when I run it, it shows the following message:
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
And when I try to use one function of the code it shows:
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.
I kinda tried to put the folder containing java.dll to the PATH in System Variables but it keeps showing the same message My SWI-Prolog is version 7.6.4 64 bits, I don't think there's nothing wrong with the code itself because there's no one complaining about it in the video I downloaded it from.
Edit: the message saying that java.dll is now gone and now there's only the 2 other messages remaining, and I've already included everything I thought it was relevant in the Path under System Variables.
Make sure that the
CLASSPATHvariable in System Variables includes the path to thejpl.jarfile that is bundled with SWI-Prolog. As in example, in my Windows 7 VM, I get from within SWI-Prolog:All of my code that uses JPL runs fine in this variable definition. In addition, loading the JPL library should print something like (assuming a recent SWI-Prolog version):
Update
Experiment with also defining the
JAVA_HOMEvariable in System Variables. I'm on macOS where I use:The path would differ on Windows and depending on the Java version you have installed but should end with
HOME.