2
votes

I'm configuring the JPL right now, and wanna work with swi-prolog using java.

I downloaded the newest stable version of SWI-Prolog, which is 6.2.0, and installed in D:\swipl

First, I added the following path to the PATH virable: D:\swipl\bin, which should include all dll files needed.

Then, I added the following path to the CLASSPATH virable: D:swipl\lib\jpl.jar, which should be the jar file needed.

When I tried to run the versions example provided, I got the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
    at jpl.fli.Prolog.thread_self(Native Method)
    at jpl.Query.open(Query.java:286)
    at jpl.Util.textToTerm(Util.java:162)
    at jpl.Query.Query1(Query.java:183)
    at jpl.Query.<init>(Query.java:176)
    at Versions.main(Versions.java:11)

After searching online, I found that many people just get java.lang.UnsatisfiedLinkError: no jpl in java.library.path which is because of the setting for the PATH variable, rather than the error I get here: java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I (and yes, there is a "I" at the end of the line).

Has anyone gotten this error before? I've tried several previous version of SWI-Prolog, but also got other kinds of errors. I'm using Eclipse IDE for Java development -- have I missed anything?

4

4 Answers

4
votes

I've sent the problem to the official mailing list ([email protected]) provided by swi-prolog.org, and luckily someone helped me to prove that there are some problems in the version 6.2.0. We then both tried the version 6.0.2, and it works perfectly. He mentioned that (and I noticed that) there is no swipl.dll in the bin folder of the version 6.2.0, which MAY causes the issue.

I've already reported the issue to the staff via Email, and at least for now, I suggest that people who want to configure JPL should download the version 6.0.2. Three things to remember:

  1. add a new variable SWI_HOME_DIR under system variables in environment variables, and set the path to the place where you installed the SWI-Prolog (Mine is D:\swipl);

  2. Add the path %SWI_HOME_DIR%\bin to your PATH variable, rather than use something like "D:\swipl\bin". (Otherwise [FATAL ERROR: Could not find system resources] will occur)

  3. Add the path %SWI_HOME_DIR%\lib\jpl.jar to your PATH variable, rather than use something like "D:\swipl\lib\jpl.jar". (Otherwise [FATAL ERROR: Could not find system resources] will occur)

If you are using Eclipse for Java development, it seems that you DO NOT need to configure in your IDE. As long as you follow the 3 steps above and add the correct jar file as an external library, it should be fine.

I'm not sure whether the temporary solution works for everyone, but definitely, everyone who has the issue should try this method first. As long as the issue in the version 6.2.0 has been figured out, I'll add some comments here.

BTW, as far as I know, until now, people who have the issue are using 32-bit Windows.

2
votes

Try adding your path to java.library.path via Run > Run Configuration > [project name] and add the following under "VM Arguments" tab.

-Djava.library.path="D:\swipl\bin;."

Furthermore, under the "Environment" tab, add the following:

VARIABLE: PATH
VALUE: D:\swipl\bin;${env_var:PATH}

After that, go to Project > Properties > Java Build Path, select "Libraries" tab. Click "Add External JARS.." and find your jpl.jar.

0
votes

Great Great Great, second answer is the solution

  1. create SWI_HOME_DIR variable to set the swi prolog instalation directory SWI_HOME_DIR ------- C:\Program Files\swipl
  2. set PATH to point to the library and bin like this PATH ------ %SWI_HOME_DIR%\bin;%SWI_HOME_DIR%\lib\jpl.jar

This fix my problem "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path windows" it is a little bit rare but it works find.

0
votes

I had the same problem. In addition to set the PATH, you need to verify if the installed SWI program has the same architecture (32 or 64) of your JVM.