Java/Prolog interface (SWI Prolog JPL) up running!

Install notes for SWI Prolog JPL on Ubuntu Jaunty (9.04)

JPL is a bi-directional Java/Prolog interface for SWI-Prolog, which I hope to be able to use for integrating Blipkit into Bioclipse, so I'm happy to have got it up running tonight. Below are some notes from the installation procedure.

NOTE: These are still rather incomplete notes about how to get this to work. Hope to make it into a verified tutorial later (I unfortunately haven't documented each and every step I took to get it working :( , so I might need to redo the install on a virtual machine to be sure)

I have followed the installation instructions on this page. (this page has some hints too).

JPL is not included in the Ubuntu repositories :( (only available for ubuntu 8.10 i think), so I had to install SWI-Prolog from source, which went Ok. I happened to install, among others, the following packages, which seemed like they were neede (though that is not verified):

  • libjpeg-dev
  • libxpm-dev
  • libx11-dev

The XPCE package still can't be built though. (Says that it is missing "-lXpm")

EDIT: I found out (with the help of this thread) that I needed to install libxt-dev, which is available in the Ubuntu repos!

Then I copied

~/install/swi-prolog/pl-5.6.64/packages/jpl/libjpl.so

into

/usr/lib/swi-prolog/library/jpl/libjpl.so

I also made symlinks in /usb/bin, like so:

/usr/bin/libjava.so -> /usr/lib/jvm/java-1.5.0-sun/jre/lib/i386/libjava.so
/usr/bin/libjpl.so -> /home/samuel/install/swi-prolog/pl-5.6.64/packages/jpl/libjpl.so

Had to add the libjava.so to my PATH, by means of:

export PATH="/usr/lib/jvm/java-1.5.0-sun-1.5.0.19/jre/lib/i386/libjava.so":$PATH

For the prolog demo to work, I had to do:

export LD_LIBRARY_PATH=/usr/lib/jvm/java-1.5.0-sun-1.5.0.19/jre/lib/i386/:/usr/lib/jvm/java-1.5.0-sun-1.5.0.19/jre/lib/i386/client

(This discussion was very helpful for this.)

Now it works! I fire up swi-prolog with "pl" (If you have installed SWI-Prolog as an ubuntu package, you might need to use "swipl" or "swi-prolog"), and, standing in ~/install/swi-prolog/pl-5.6.64/packages/jpl/examples/prolog, I can now write (inside the prolog console):

[jpl_versions_demo].

(That will load the jpl_versions_demo.pl file located in the directory where I started prolog)

Result is:

?- [jpl_versions_demo].
%    library(error) compiled into error 0.01 sec, 9,676 bytes
%   library(lists) compiled into lists 0.01 sec, 23,424 bytes
%  library(jpl) compiled into jpl 0.07 sec, 287,052 bytes
 
prolog library version: 3.1.4-alpha
  java library version: 3.1.4-alpha
     c library version: 3.1.4-alpha
BINGO! you appear to have the same version of each library installed
 
% jpl_versions_demo compiled 0.13 sec, 304,240 bytes
true.
 
?-  

D

The Java examples in examples/java/* work as well. cd:ing into

~/install/swi-prolog/pl-5.6.64/packages/jpl/examples/java/Family

and running
sh run.sh

gives the following output:
JPL demo: Family
 
% family.pl compiled 0.00 sec, 2,632 bytes
consult('family.pl') succeeded
child_of(joe, ralf) is provable
descendent_of(steve, ralf) is provable
first solution of descendent_of(X, ralf): X = joe
all solutions of descendent_of(X, ralf)
X = joe
X = mary
X = steve
each solution of descendent_of(X, ralf)
X = joe
X = mary
X = steve
each solution of descendent_of(X,Y)
X = joe, Y = ralf
X = mary, Y = joe
X = steve, Y = joe
X = mary, Y = ralf
X = steve, Y = ralf

(If this is not working next time I log in / reboot, I guess I'll have to add the LD_LIBRARY_PATHs in a more permanent way. Have to figure out how...).

Possible next steps

  • See if I can communicate with Prolog from a Bioclipse plugin as well
    • (Will probably include the task to add the .so libraries above, into the path of the JRE that Bioclipse is using etc.)
  • Figure out how to talk specifically to blipkit (or the swi-prolog version which has the blipkit modules loaded)
  • Do all kinds of interesting stuff with BLIPKIT in Bioclipse :)
  • At last: Figure out how to package he whole thing in a neat way for easy installation etc.

Comments

Samuel, Java 5 is about to go

Samuel, Java 5 is about to go MIA, due to EOL... can you also try with OpenJDK6?

BTW, this is something of more general importance to Bioclipse...

Yes, thanks for pointing that

Yes, thanks for pointing that out. I was thinking a bit of that too. I now used only the Java 5 version as that was recommended in a tutorial, but it would indeed be worth to try to get it working with Java 6.

Can't get around undefined symbol: PL_is_initialised

Hi there. I'm trying installing JPL with pl 5.10. Following these useful instructions, the prolog examples actually work:

?- [jpl_versions_demo].
% library(error) compiled into error 0.01 sec, 10,192 bytes
% library(lists) compiled into lists 0.01 sec, 25,096 bytes
% library(jpl) compiled into jpl 0.05 sec, 397,612 bytes

prolog library version: 3.1.4-alpha

  java library version: 3.1.4-alpha
     c library version: 3.1.4-alpha

BINGO! you appear to have the same version of each library installed

but, I can't get around java's

JPL demo: Family

java: symbol lookup error: /usr/local/lib/swipl-5.10.1/lib/i686-linux/libjpl.so: undefined symbol: PL_is_initialised

Any advice?. Thanks

Hi! I hope to find time soon

Hi!

I hope to find time soon to test these things out a bit again, as I'll soon make sure the Bioclipse/SWI-Prolog plugin works with the latest version of Bioclipse.

In the meanwhile, this discussion seem to be relevant.

Cheers,
Samuel