Connect between java and swi proog

I am trying to run swi proog from java
I use eclipse and I injected jpl.jar into the project (properties-> libraries-> add external jar) and when I try to run the program (this is a jpl sample, so it should work ..) I get the error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1045) at jpl.JPL.loadNativeLibrary(JPL.java:100) at jpl.fli.Prolog.<clinit>(Prolog.java:85) at jpl.Query.open(Query.java:286) at jpl.Util.textToTerm(Util.java:162) at jpl.Query.<init>(Query.java:198) at faf.Main.main(Main.java:10) <br> 

What am I missing?

+4
source share
4 answers

I had this problem today on Debian, and my solution was similar to Felix Dobslaw's. Since I could not find it elsewhere, I will post how I solved it today.

My SWI-Prolog and JPL were installed via apt-get. Change the folder folders to suit your conditions.

  • Copy libswipl.so from /usr/lib to usr/lib/swi-prolog/lib/amd64

    ( sudo cp <probably-user-lib>/libswipl.so <installation-folder-swi>/lib/<architeture> )

  • Add -Djava.library.path="/usr/lib/swi-prolog/lib/amd64" as a VM option

    (Project Properties → Run → Virtual Machine Settings)

+2
source

Depending on your platform, there should be a dll jpl or so on. You must either make it available somewhere in% PATH%, or specify its location using the -Djava.library.path=<path to jpl.dll> java -Djava.library.path=<path to jpl.dll> .

Read more about Installing JPL

+1
source

I had the same problem. This helped me on Ubuntu:

1) Indicate the location of your own jpl jar library in the folder where you keep your "libswipl.so" (I do this using the settings of the "Java Build Path" project). For me it:

/usr/lib/swipl-6.2.6/lib/x86_64-linux

2) Add the folder in which you keep your "libjava.so" in your LD_LIBRARY_PATH variable (I do this in my runtime configuration on the "Environment" tab). For me it:

/ USR / Library / JVM / Java-6-OpenJDK / JRE / Library / amd64

+1
source

Solution for Eclipse Neon and homebrew:

 brew update brew install swi-prolog --with-jpl 

In the Eclipse setup, Run / Debug-Configuration is set as VM-Arg:

 -Djava.library.path=/usr/local/Cellar/swi-prolog/7.4.2/libexec/lib/swipl-7.4.2/lib/x86_64-darwin16.6.0 

Actual paths may vary.

0
source

Source: https://habr.com/ru/post/1441168/


All Articles