JPL architecture & components
The first thing to understand is that JPL has three parts:
- C code (in
src/c
) implementing the bridge between Java and SWI Prolog (as installed in the specific architecture where execution will happen). This code uses the Java Native Interface (JNI) programming framework, and is basically filesrc/c/jpl.c
- Check this and this tutorials for understanding how JNI can be used. Also check IBM’s Best practices for using the Java Native Interface
- Java code (in
src/java
) implementing the Java-side API interface of JPL to access Prolog. Basically this is a set of objects and methods to use SWI Prolog from Java. For example, objects that represent Prolog atom and terms, and methods to prove a goal and access the solution bindings. - Prolog code (basically
jpl.pl
) implementing the Prolog API for access Java, for example to create an object or call a method of a given object. The reference documentation for the Prolog API can be found here too.
Both the Java and Prolog sources will make use of the C JNI code.