特にJavaはVMを介して実行されるため、これが可能かどうかはわかりませんが、Java内からgnuplotを呼び出すことはできますか? おそらく、Javaにターミナルを開いて入力させることができます
gnuplot
plot ...
等?
gnujavaplotを使用します。
gnuplot がコマンドラインまたは標準入力からすべての入力を取得 (またはファイルから読み取り) し、その出力をファイルに書き込むことができる場合は、ProcessBuilder
.
JavaGnuplotHybrid ライブラリを使用します。
これは非常に軽量 (3 つのコア クラスのみ) であり、Java と Gnuplot を使用したハイブリッド プログラミングを可能にします。
詳細については:
これは Debian で動作します:
String[] s = {"/usr/bin/gnuplot",
"-e",
"set term jpeg large size 800,600;set autoscale; set grid;set format y \"%0.f\";set output \"plot.jpg\";set xdata time;set timefmt \"%Y-%m-%d-%H:%M:%S\";set xlabel \"Dates\";set ylabel \"Data transferred (bytes)\";plot \""+x+"\" using 1:2 title \"Total:"+tot+"\" with linespoints;"
};
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(s);
InputStream stdin = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null)
System.err.println("gnuplot:"+line);
int exitVal = proc.waitFor();
if (exitVal != 0)
log("gnuplot Process exitValue: " + exitVal);
proc.getInputStream().close();
proc.getOutputStream().close();
proc.getErrorStream().close();
} catch (Exception e) {
System.err.println("Fail: " + e);
}
「exec」コマンドを使用して、任意の外部アプリケーションを起動できます。
http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html
いくつかの例については、このページを参照してください。 http://www.rgagnon.com/javadetails/java-0014.html
編集: ProcessBuilder を忘れていました。Michael Borgwardt の答えは、より堅牢なソリューションです。