For anyone not using Java, the problem can be reproduced from the shell like this:
gnuplot <<EOF
p sin(x), cos(x), '-'
0 0
1 1
2 2
e
set term png
set out 'plt.png'
rep
EOF
You can get round it by plotting the data from stdin
to an intermediate table:
gnuplot <<EOF
set table 'term1.dat'
plot '-'
0 0
1 1
2 2
e
unset table
plot sin(x), cos(x), 'term1.dat'
set term png
set out 'plt.png'
rep
EOF