Go to the first, previous, next, last section, table of contents.


Jasper notes

Jasper is a bi-directional interface between SICStus Prolog and Java. It is currently built on top of the JNI together with the C-Prolog interface, and hence makes use of the native keyword in Java.

Requirements, Availability, and Limitations.

Jasper is available on the following platforms:

Solaris 2.x (x86, SPARC)
Tested using Sun's JDK 1.1.x, downloadable from
http://java.sun.com/products/jdk/1.1/ 
Windows 95/98/NT
Tested using Sun's JDK 1.1.x, downloadable from
http://java.sun.com/products/jdk/1.1/ 

Jasper should be able to use any Java-implementation as long as it is JNI-compatible. Doing this, however, requires a source distribution since the Jasper-module needs to be built. Refer to the source code installation instructions for more details.

Using Jasper from applets: Since Jasper relies on calling methods declared as native, Jasper cannot be used from within an applet. This is due to a security-restriction enforced on applets; they are not allowed to call native code.

Note: Be wary when using terminal-I/O routines in Java code called from within Prolog. This is known to crash the Prolog process on some configuration.

The interface can be used in two different ways (but see the section on "limitations" above), depending on which language is used at toplevel. Either SICStus is loaded as a runtime-system into Java:

% java JasperTestClass

or Java can be loaded into SICStus as a foreign resource:

% sicstus
SICStus 3.7: Mon Mar  2 19:22:44 MET 1998
| ?- use_module(jasper).
...

Platform Specific Notes

Creating Foreign Resources for Jasper under Windows

When calling Java from Prolog, a foreign resource must be created using splfr, as described in the User's Manual. This resource must be linked with the JVM (javai.dll or libjava.so). Under UNIX, splfr automatically detects that a Java method is called and passes the correct flags to the linker. Under Windows, however, splfr takes an additional option -java=JAVADIR to indicate that the resource should be linked with the JVM. Also, the Java and Jasper link-flags need to be specified explicitly as a +l option to splfr.

% splfr simple simple.pl -java=c:\jdk1.1.5 +dynamic \
           +l c:\jdk1.1.5\lib\javai.lib %SP_PATH%\library\jasper.lib     

Runtime requirements

When using Java as toplevel application

The path to the SICStus library must be included in CLASSPATH (see the documentation of your Java implementation for more details about how to set this variable). For example, under UNIX:

% java -classpath $CLASSPATH:/usr/local/lib/sicstus37/library Class

or under Windows:

% java -classpath "%CLASSPATH%;c:\Program Files\sicstus37\library" Class

Also, the runtime linker must be able to locate the SICStus runtime kernel. This is usually handled automatically when running SICStus, but when Java is used as toplevel application, the system will usually not know where your SICStus application resides.

Under UNIX this is handled by setting the runtime linker search path variable (usually LD_LIBRARY_PATH) to contain the path to the SICStus runtime kernel (`libsprt37.so'), and by setting SP_PATH to point out the location of the Runtime Library. If you are unsure of what to set these variables to, a look in the SICStus start-script can be helpful.

Under Windows, `sprt37.dll' must be located in one of the placed the runtime linker searches in; the same directory as the executable, the current directory, or the directories specified by PATH (which includes the system directories).

When using SICStus as toplevel application

Under UNIX, the SICStus start-script sets LD_LIBRARY_PATH and CLASSPATH to their correct values, so there is no need to set any environment variables manually.

Under Windows, the runtime linker must be able to locate the Java runtime kernel `javai.dll', according to the same rules as above (i.e. for `sprt37.dll'). The classpath variable is taken from the environment variable CLASSPATH which therefore must contain the correct value.


Go to the first, previous, next, last section, table of contents.