Subject: Re: Launching Prolog from Java

From: Fred Dushin <[email-masked]>
Date: Fri, 17 Nov 2000 08:51:42 -0500 (EST)

> 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