From pnugues@greyc.ismra.fr  Fri Nov 17 17:26:44 2000
Received: from greyc.ismra.fr (l2i.greyc.ismra.fr [192.93.101.84])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id RAA15213
	for <prolog@swi.psy.uva.nl>; Fri, 17 Nov 2000 17:26:44 +0100 (MET)
Received: from penelope (penelope.greyc.ismra.fr [192.93.101.198])
          by greyc.ismra.fr (8.9.3/greyc-1) with SMTP id RAA04411
          ; Fri, 17 Nov 2000 17:28:57 GMT
Message-ID: <00c501c050b3$41824b80$c6655dc0@greyc.ismra.fr>
Reply-To: "Pierre Nugues" <pnugues@greyc.ismra.fr>
From: "Pierre Nugues" <pnugues@greyc.ismra.fr>
To: <prolog@swi.psy.uva.nl>
Cc: <fadushin@syr.edu>, "Steffen Moeller" <moeller@ebi.ac.uk>,
        <p.singleton@keele.ac.uk>
References: <Pine.SOL.4.10.10011170851040.25948-100000@apollo.ecs.syr.edu>
Subject: Re: Launching Prolog from Java
Date: Fri, 17 Nov 2000 17:27:18 +0100
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

Dear Steffen, Fred, and Paul,

Thank you for pointing me to the Process class. It's exactly what I was
looking for.

I tried a small code to write and read data from Prolog. I used the Process
class in a Java program and I wrote a small loop to do I/O that I redirected
to Prolog using the getInputStream and getOutputStream methods. I wrote a
symmetrical I/O loop in Prolog using get0/1 read/1 and write/1.

Java launched the plwin.exe correctly but nothing happened with the I/O.
Prolog prompts me |: and still attempts to read from the keyboard and
apparently doesn't receives any data from Java. Something seems to happen
however when I close Prolog using ^C.


Do you know why or do you have a complete small code sample. I'm using Win98
and Plwin.exe

Many thanks
Pierre
--
Pierre Nugues, Professeur d'informatique (pnugues@greyc.ismra.fr)
ISMRA, 6, bd du Maréchal Juin, F-14050 Caen, France
Tél. (33) 231-452-705 -- Fax. (33) 231-452-760
http://www.ensicaen.ismra.fr/~nugues
----- Message d'origine -----
De : "Fred Dushin" <fadushin@syr.edu>
À : "Pierre Nugues" <pnugues@greyc.ismra.fr>
Cc : "Recipients of SWI-Prolog Mailing List" <prolog@swi.psy.uva.nl>
Envoyé : vendredi 17 novembre 2000 14:51
Objet : Re: Launching Prolog from Java


> > I would like to launch SWI-Prolog from Java. I just need to redirect
> socket
> > streams to Prolog's standard input and output before launching it. It's
> > fairly easy to do that with Unix and C with dup() and execv().
> >
> > There is an exec() method in Java but apparently it doesn't enable
> stream
> > passing.
> > Is there a workaround?
>
> If I understand what you are trying to do, why not just use the
> get(Input|Output)Stream method on the Process you get back from
> Runtime.exec()?  With that stream, you can send bytes down the
> pipe to prolog using the output stream, and you can read the
> response from prolog by picking bytes off the input stream.
> You don't need to do any sockets programming for this (though
> I suppose you could...)
>
> > PS I know of JPL. I would like to know whether there is something
> simpler
>
> I've used both the technique described above and (I wrote) JPL.
> I think using JPL is actually simpler and will generally be more
> robust.  Streams can be very tempermental.
>
>
> --
> Fred Dushin <fadushin@syr.edu>
>
> vi rulse!^H^H^Hes!
> `:wq
>

