tags:

views:

36

answers:

3

I'm not sure if this is possible, especially since Java runs through a VM, but can I call gnuplot from within Java? Perhaps I could have Java open a terminal and input

gnuplot
plot ...

etc?

+1  A: 

If you can get gnuplot to take all input from the command line or standard input (or read it from a file) and write its output to files as well, then there should be no problem doing this using ProcessBuilder.

Michael Borgwardt
I did something similar a while back. I'm hazy on the details, but I can confirm Gnuplot is happy to slurp all of its input from files. It's very scriptable.
Carl Smotricz
A: 

You can launch any external application using the "exec" commands.

http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html

See this page for a few examples. http://www.rgagnon.com/javadetails/java-0014.html

EDIT: I forgot about ProcessBuilder. Michael Borgwardt's answer is a more robust solution.

Tansir1
+2  A: 

Use gnujavaplot.

mcandre
Perfect! Thank you.
Earl Bellinger