Next: , Up: lib-jasper   [Contents][Index]


10.19.1 Jasper Overview

Jasper is a bi-directional interface between Java and SICStus. The Java side of the interface consists of a Java package (se.sics.jasper) containing classes representing the SICStus runtime system (SICStus, SPTerm, etc). The Prolog part is designed as a library module (library(jasper)).

Please note: If only uni-directional communicaton from Java to Prolog is needed, then the newer library('jsonrpc/jsonrpc_server') (see lib-jsonrpc) is probably an easier way to expose a Prolog program to a client written in some other programming language, such as Java. One advantage is that it uses a standardized, text-based, protocol for communication, which makes it easier to integrate with arbitrary client languages (not just Java), test, and troubleshoot. Like the Jasper library the JSON-RPC library gives the client access to the full power of Prolog, including backtracking and constrained variables.

The library module library(jasper) (see The Jasper Library) provides functionality for controlling the loading and unloading the JVM (Java Virtual Machine), method call functionality (jasper_call/4), and predicates for managing object references.

Jasper can be used in two modes, depending on which system acts as Parent Application. If Java is the parent application, then the SICStus runtime kernel will be loaded into the JVM using the System.loadLibrary() method (this is done indirectly when instantiating a SICStus object). In this mode, SICStus is loaded as a runtime system (see Runtime Systems).

As of release 3.9, it is possible to use Jasper in multi threaded mode. This means that several Java threads can call SICStus runtime via a server thread. The communication between the client threads and the server thread is hidden from the programmer, and the API is based on Java Interfaces, which are implemented both by the multi thread capable classes and the pre-3.9 classes, which are restricted to single threaded mode. The decision whether to run in single thread mode or in multi threaded mode can thus be left until runtime.

If SICStus is the parent application, then Java will be loaded as a foreign resource using the query use_module(library(jasper)). The Java engine is initialized using jasper_initialize/[1,2].



Send feedback on this subject.