From fadushin@syr.edu  Fri Nov 17 14:51:42 2000
Received: from mailroom.ecs.syr.edu (ecs.syr.edu [128.230.208.14])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA05739
	for <prolog@swi.psy.uva.nl>; Fri, 17 Nov 2000 14:51:41 +0100 (MET)
Received: from apollo.ecs.syr.edu (apollo.ecs.syr.edu [128.230.208.46])
	by mailroom.ecs.syr.edu (8.10.2/8.10.2) with ESMTP id eAHDpgY12351;
	Fri, 17 Nov 2000 08:51:43 -0500 (EST)
Date: Fri, 17 Nov 2000 08:51:42 -0500 (EST)
From: Fred Dushin <fadushin@syr.edu>
X-Sender: fadushin@apollo.ecs.syr.edu
Reply-To: fadushin@syr.edu
To: Pierre Nugues <pnugues@greyc.ismra.fr>
cc: Recipients of SWI-Prolog Mailing List <prolog@swi.psy.uva.nl>
Subject: Re: Launching Prolog from Java
Message-ID: <Pine.SOL.4.10.10011170851040.25948-100000@apollo.ecs.syr.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

> 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

