Node:Interfacing with Java, Previous:Interfacing with Tcl/Tk, Up:Interfacing with Other Languages



Interfacing with Java

Question:
I'm having basic trouble in getting Java to work.

First try to get a simple "Hello world" program to work that does not use Jasper. A large portion of the support questions we get are unrelated to the SICStus Java interface. Once you can compile and run your own Java classes it should be relatively easy to get Jasper to work.

Read the Release Notes and the User's Manual and the section in them related to Jasper.

Question:
I want to use Jasper from an applet, but my browser won't let me.

Jasper is built as a layer on top of SICStus' C-Prolog interface and hence Jasper needs to be able to call methods declared as native (i.e., C functions). For security reasons, this is prohibited in applets.

This is a serious restriction, and future versions of Jasper will most likely allow connecting to the Prolog engine via sockets. In the interim, there are some examples on this at the Don't Panic page at http://www.sics.se/sicstus/.

Question:
I get the message "Failed to locate bootfile" when running java ClassUsingJasper.

The answer to this (and related questions) can be found in the Jasper chapter of the Release Notes, section "Getting Started".

Question:
My first test of Java calling SICStus under MacOS X (i.e. calling se.sics.jasper.SICStus) failed with the following message. Yes, I set the java.library.path.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/ptollinger/bin/powerpc-apple-darwin/lib/libspnative.jnilib:
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1485)
        at java.lang.Runtime.loadLibrary0(Runtime.java:788)
        at java.lang.System.loadLibrary(System.java:834)
        at se.sics.jasper.SICStus.loadNativeCode(SICStus.java:491)
        at se.sics.jasper.SICStus.initSICStus(SICStus.java:749)
        at se.sics.jasper.SICStus.<init>(SICStus.java:811)
        at se.sics.jasper.SICStus.main(SICStus.java:439)

You need to set DYLD_LIBRARY_PATH to include the SICStus runtime library:

bash> export DYLD_LIBRARY_PATH=location of libsprt312.dylib