Subject: Re: Launching Prolog from Java

From: Steffen Moeller <[email-masked]>
Date: Fri, 17 Nov 2000 16:58:38 +0000 (GMT)

My stand approach to this is to have
a dummy program that you know to work
to execute the output you expect.
Wrap that for a test.

Maybe plwin does not read from stdin.
You might want to check this as well.

Sorry, I'm not a windows programmer.

Steffen 

On Fri, 17 Nov 2000, Pierre Nugues wrote:

> 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 ([email-masked])
> 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" <[email-masked]>
> À : "Pierre Nugues" <[email-masked]>
> Cc : "Recipients of SWI-Prolog Mailing List" <[email-masked]>
> 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 <[email-masked]>
> >
> > vi rulse!^H^H^Hes!
> > `:wq
> >
> 
> 
> ----------------
> * To UNSUBSCRIBE, please use the HTML form at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
> 
> or send mail to [email-masked] using the Subject: "unsubscribe"
> (without the quotes) and *no* message body.
> 
> ** An ARCHIVE of this list is maintained at
> 
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
> 
> 

    Steffen Moeller <[email-masked]>    ICQ 37032340