I wanted to connect Java and Swi Prolog together using JPL. When I added the library to my project on Intellij the code compiled and when I tried to run a query I got a runtime error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path: [C:\Program Files\Java\jdk-12\bin, C:\WINDOWS\Sun\Java\bin, C:\WINDOWS\system32, C:\WINDOWS, c:\swipl\bin, ${env_var:PATH}, .]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:827)
at java.base/java.lang.System.loadLibrary(System.java:1902)
at org.jpl7.JPL.loadNativeLibrary(JPL.java:114)
at org.jpl7.fli.Prolog.<clinit>(Prolog.java:71)
at org.jpl7.Query.open(Query.java:369)
at org.jpl7.Term.textToTerm(Term.java:155)
at org.jpl7.Query.<init>(Query.java:169)
at Main.main(Main.java:7)
I have the swi prolog 64 bit.
I've tried uninstalling it and use the 32 bit but it did not work.
What I did so far:
I added SWI_HOME_DIR to my Environment Variables. I also added the swi path to Path variable. I added the jpl library to my project (and it added it successfully).
The code I was trying to run:
import org.jpl7.*;
import java.util.Map;
public class Main {
public static void main(String[] args) {
Query q = new Query("true");
q.hasSolution();
Map<String,Term>[] res = q.allSolutions();
for (int i = 0; i < res.length; i++) {
System.out.println(res[i]);
}
}
}
jpl.dll
can go in any folder on yourPATH
; perhaps%SWI_HOME_DIR%\bin
or your Windows’ system folder." --- Is thejpl.dll
file there, in a folder listed on your PATH? Is it the 64-bit version? I'm not asking if thebin
folder is on your path, I'm asking if that specific file can be found on the path. – Andreasdir c:\swipl\bin\jpl.dll
from a command prompt, it will list the file? And you are running 64-bit Java? And you are sure the file is the 64-bit version? If yes to all, then the file might be corrupt, to try getting another copy. – Andreasjpl.dll
. I even bolded it so you could see, but I guess you didn't. – Andreas