Using JPL Package in Debian
===========================

Using Prolog from Java Programs
-------------------------------

Compiling or running Java programs requires adding jpl.jar to
Java class path, for example by using -classpath command line
argument or CLASSPATH environment variable:

    $ javac -classpath /usr/share/java/jpl.jar Class.java
    $ java -classpath /usr/share/java/jpl.jar:. Class

Using Java from Prolog Programs
-------------------------------

Prolog programs that use Java require additional settings in
order to load various Java libraries. LD_LIBRARY_PATH should be
modified so that it contains directories that contain libjava.so,
libjni.so, libjsig.so, and maybe some other Java libraries.

The command line for the prolog interpreter could look like this
(on amd64 system, using OpenJDK):

   $ LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64 swipl

Other architectures and JDK versions require different settings.
A typical error message with incorrect library path setting could
look like this:

   $ swipl
   ...
   ?- use_module(library(jpl)).
   ERROR: /usr/lib/swi-prolog/library/jpl.pl:4637:
           '$open_shared_object'/3: libjsig.so: cannot open shared object file: No such file or directory
   ERROR: /usr/lib/swi-prolog/library/jpl.pl:4637:
           library `java' does not exist (Please add directory holding libjava.so to $LD_LIBRARY_PATH)

The error messages indicate that directories that contain libjsig.so
and libjava.so should be added to LD_LIBRARY_PATH. You then can use
the following command to find out location of those files:

   $ dpkg --search libjsig.so libjava.so

Choose directories that belong to your preferred Java runtime version.

Please report any other encountered problems or possible fixes for
described problems to Debian BTS. Bug #690734 [1] tracks current
state of Java support in swi-prolog.


1. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=690734
