From lafeber@solveware.nl  Sat Jan 22 12:34:05 2000
Received: from mail.zonnet.nl (relay1.zonnet.nl [212.48.41.21])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id MAA02160
	for <prolog@swi.psy.uva.nl>; Sat, 22 Jan 2000 12:34:05 +0100 (MET)
Received: from chris.willi.nl ([212.48.62.51]) by mail.zonnet.nl
          (Netscape Messaging Server 4.05) with SMTP id FOQIS201.EWV; Sat,
          22 Jan 2000 12:33:38 +0100 
Message-ID: <002a01bf64cb$ccceb220$fe0aa8c0@willi.nl>
From: "Philip Lafeber" <lafeber@solveware.nl>
To: "Fred Dushin" <fadushin@syr.edu>, <prolog@swi.psy.uva.nl>
References: <200001211951.LAA22973@orion.rgv.hp.com> <3888C5F8.2550C811@syr.edu>
Subject: Interfacing Java and Prolog both ways
Date: Sat, 22 Jan 2000 11:24:14 +0100
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300

Yes indeed! We have just been working on a system in which Java is the motor
behind an 'intelligent' web application, which calls Prolog for some
reasoning tasks. But then Prolog calls back on the Java program to ask for
SQL-queries in an Access-database, since we weren't able to call to the
database directly.
We are working in B-Prolog, which is largely the same as SWI-Prolog. The
Java program incorporates a an object called prologinterface, which consists
of a function that call Prolog, called 'askQuestion' (asks Prolog to
interpret a written Dutch sentence), and several functions that can be
called by Prolog, like 'returnOutput' (delivers output in string format to
the output stream) and 'selectDBQuery' (takes paramaters from Prolog to
construct an SQL-query, then returns the result in a certain format to
Prolog).

----- Original Message -----
From: Fred Dushin <fadushin@syr.edu>
To: Ovidiu Predescu <ovidiu@cup.hp.com>
Cc: Jan Wielemaker <jan@swi.psy.uva.nl>; <prolog@swi.psy.uva.nl>
Sent: Friday, January 21, 2000 9:47 PM
Subject: Re: problem with JPL 1.0.1 and SWI Prolog 3.3.0


> > I have one question about SWI Prolog/JPL integration: is it possible to
define
> > foreign predicates in Java that could be called from Prolog? I know that
I can
> > call Prolog predicates from Java, but I didn't see anything in the
> > documentation about the other way around.
>
> This has not been implemented (yet).  It gets to the question I just
posted to
> the list: Do people *want* to see this feature?  And if so, what ideas do
you
> have about what the interfaces and architecture should be like?
>
> I'm not sure how rich the reflection APIs are in Java to make this
feasible.
> Remember, there are no predicates to call in Java.  There are classes and
class
> instances, but it's not clear how to proceed from there.  The nice thing
about
> going from Java to Prolog is that you have a nice term structure that
everything
> in Prolog fits nicely into.  But the reverse direction is not as clear to
me.
> The closest thing to me seems to be Java Reflection, since you can
traverse the
> Java type structure using it.  But it's still not clear to me how this
could be
> useful.
>
> I'm throwing these ideas out there to stimulate discussion.  I haven't
been
> thinking to heavily about this direction lately, and I'm just curious if
anyone
> has any ideas about what it should look like (no less how it should
function).
>
> Does anyone know even if this sort of thing has been done elsewhere?


