Volker van Nek <volkervannek <at> gmail.com> writes:
>
> Another way to access Maxima from Java is to use stream connections.
> There are two possible ways: Process and Socket Objects both have
> methods to get the streams.
>
> In this case you don't need to know Maxima internals. You communicate
> as a normal user.
>
> Here is a short demo of the socket version. I use netcat as the socket
> server and Maxima connects to this server as a client by -s
> portnumber.
>
> First terminal (the listening server):
> volker <at> uvw32:~$ nc -l 4711
> pid=6795
> (%i1) diff(sin(x), x);
>
> (%o1) cos(x)
> (%i2) for n thru 3 do (system("sleep 1"), print(n));
>
> 1
> 2
> 3
> (%o2) done
> (%i3) quit();
> volker <at> uvw32:~$
>
> Second terminal (the Maxima core as a client):
> volker <at> uvw32:~$ maxima -q -s 4711
> Connecting Maxima to server on port 4711
> volker <at> uvw32:~$
>
> netcat has independend input and output threads. That's what I would
> recommend if you choose this way for Java. So you don't have to worry
> how Maxima finishes its ouput (there is no linebreak at the end!). And
> you don't need to know when it finishes. E.g. the above loop prints
> are displayd as intended.
>
> Volker van Nek
>
Yes. There are many ways to call maxima top-level function from java
programs.The approach you provided is very novel. Another way is to
use Jacomax (Java Connector for Maxima) which is a basic Java interface
for the Maxima computer algebra system
(https://www.wiki.ed.ac.uk/display/Physics/Jacomax). However, all these
methods could only (I think) access the top-level maxima function which will
return a 2D display string.
In some cases, one would like to have a fine control over maxima functionality
and would use maxima as a back-end computing engine and use the returned
result for further algebraic manipulation from java (e.g. writing your
own $Diff function) In this case, calling maxima top-level function would
not be sufficient?