kprolog K-Prolog Compiler Version 6.0

Java Interface to Prolog

JIPL: Java Interface to Prolog

Release| FAQ| Requirement| Class API| IDE| Installation| License

Japanese

This package, named JIPL, gives interface between Java and Prolog.
With this package, you can

  1. call Prolog predicate from Java application/applet.
  2. call Java methods, access fields of object from Prolog programs.


Release Notes and known problems

2001/09/24 JIPL version1.3
  • Fixed the case "sucsess() method not found".
2000/10/13 JIPL version1.2.1
  • Fixed a sirious error in backslash treatment in the IDE.


Requirement


Packaging

In this package, you can find minimal configuration of K-Prolog to work with JIPL. K-Prolog is a commercial product, though, you may use it with JIPL.
K-Prolog Users manual, compiler loadmodule and other stuffs are not included in this package.

You can find K-Prolog Users manual at http://www.kprlog.com/ . There is an English version now.


Downloading and installation

Download from archives, Unzip the archive and place the contents in a directory.
Before unzipping, you must remove old JIPL beta files and directories.
UNIX directory candidate is /usr/local/plc/
Windows directory candidate is C:\plc\

and set the directory to environment variables PLC and PATH.
You should also set LD_LIBRARY_PATH, and may specify through 
BROWSER variable, which browser to use, if you are using UNIX,
to show help. Or, Netscape Communicator/Navigator users can
specify MOZILLA_HOME, instead.
i.e.

unix % setenv PLC /usr/local/plc
unix % setenv PATH $PLC:$PATH
unix % setenv LD_LIBRARY_PATH $PLC:$LD_LIBRARY_PATH
unix % setenv MOZILLA_HOME /usr/local/netscape
win32> set PLC=C:\plc
win32> set PATH=%PLC%;%PATH

Set the Java classpath to the directory.
For example,

unix % java -classpath $PLC:$JAVA_HOME/lib/classes.zip


Examples

You can find 8-Queens animation in examples/queens --
Adjust Makefile lines
PLC = 
JAVA_HOME = 
to fit with your environment.
Then

> make run

gives animated solution of 8-Queens problem.
This example is incomplete as a Java animation. My aim is to show how JIPL interfaces Prolog and Java, and omitted unnecessary code.

Another example shows how to background the prolog thread --
You can find this one in examples/client.

example/ide contains an IDE example --
In this directory,
% jipl

starts the JIPL/IDE.
Then you may try
[Reconsult] and select queens.pl,
type in "queens(Q)" to [TextField] to run the program.
To erase the board, type in "dispose".


Class API

In the class com.kprolog.plc.Plc class,
you may mainly use the methods,

startPlc(String[] args)
exec(String command)
call(String functor, Object[] args)
run()


Prolog API

javaConstructor(Class(Args,...), Instance)
    Class(+atom)    : Java class name, with full package path.
    Args(+term)     : Arguments to be passed to the constructor.
                      Don't use () if the constructor has no argument.
                      Place just an atom as Class instead.
    Instance(-term) : Instance created.

    Calls constructor of Java object.

javaMethod(ClassOrInstance, Method(Args,...), Return)
    ClassOrInstance : Class or Instance.
    Class(+atom)    : Java class name, with full package path.
    Instance(+term) : An instance.
    Args(+term)     : Arguments to be passed to the constructor.
                      Don't use () if the method has no argument.
                      Place just an atom as Method instead.
    Return(-term)   : Returned object from the method. Remain intact if 
                      the method is void type.

    Calls a static method of a class, if ClassOrInstance is an atom.
    Calls an instance method, if an instance is given.

javaGetField(ClassOrInstance, Field, Value)
    ClassOrInstance : Class or Instance.
    Class(+atom)    : Java class name, with full package path.
    Instance(+term) : An instance.
    Field(+atom)    : Field name.
    Value(-term)    : Value of the field.

    Gets the value of the field.

javaSetField(ClassOrInstance, Field, Value)
    ClassOrInstance : Class or Instance.
    Class(+atom)    : Java class name, with full package path.
    Instance(+term) : An instance.
    Field(+atom)    : Field name.
    Value(+term)    : Value to be set to the field.

    Sets the value to the field.


Data conversion

    Java        Prolog
    ---------------------------
    Integer     32bit integer
    Double      64bit float
    Long        (may be bignum)integer
    BigInteger  (may be bignum)integer
    String      string (list of char code)
    Array       list
    Other       address term


Development environment

% jipl
starts the JIPL/IDE.
It is a shell script or batch file, which starts sample Prolog IDE. I abandoned using Java Invocation interface, for porting reasons. You can use it with environment variables PLC and JAVA_HOME set.

Source is available under src/ide directory, but you can't find any document.
I call this "IDE", but it contains no editor. [File]-[Edit] starts "vi" in default. With editor(EditorName) prolog builtin, you may specify an editor you use.

Example of IDE usage.

(NOTE)


TODO


License

Permission to use, copy, modify, and distribute this release of the software for RESEARCH/EVALUATION purposes and without fee is hereby granted provided that this copyright notice appears in all copies. Notice that EDUCATIONAL purpose usage is NOT granted.

The Java package name, com.kprolog.plc, is reserved for KLS Research, Inc. So you should rename the package when you apply JIPL to other language processors.

Nobukuni Kino and KLS Research, Inc. make no warranties about the suitability of the software, either expressed or implied, fitness for a particular purpose. Nobukuni Kino and KLS Research, Inc. shall not be liable for any damages suffered by licensee as a result of using, modifying or distributing this software or its derivatives.


Commercial package

K-Prolog Compiler version 5.0 is the full set commercial package.
Personal users may download it through HTTP.

Contact info@kprolog.com and purchase LICENSE FOR COMMERCIAL or EDUCATIONAL purpose.


Please report any problems or proposals to kino@kprolog.com (Nobukuni Kino) KLS Research Lab.


ܼ