Sparklines for JAVA

Finally, I could find the java implementation for sparklines following are the two links

This one requires java1.5

For java 1.4 and lower check this out

For the above JSparkline I have implemented the antialiasing feature and also the slices for the pie chart.

Before antialising PieChart BeforeAreaChart Before LineChart Before and after PieChart After AreaChart After LineChart After

Sliced Pie Sliced Pie with border Sliced Pie


Why runtime.exec hangs in Java ?

I had hit with the same problem runtime.exec() hangs when I tried to execute a lengthy batch script in windows. The Java docs had apparently described this which I never read. RTFM 😉

“Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.”

The solution was to empty the buffer so that the process won’t hit a deadlock. I have a small sample which could make you clearer.


public class ProcessHandler extends Thread {
    InputStream inputStream;
    String streamType;

    public ProcessHandler(InputStream inputStream, String streamType) {
        this.inputStream = inputStream;
        this.streamType = streamType;

    public void run() {
        try {
            InputStreamReader inpStrd = new InputStreamReader(inputStream);
            BufferedReader buffRd = new BufferedReader(inpStrd);
            String line = null;
            while ((line = buffRd.readLine()) != null) {
                System.out.println(streamType+ “::” + line);
        } catch (Exception e) {

    public static void main(String args[]) throws Exception {
        /* For windows setting to cmd.exe */
        String command[] = {
            “cmd.exe”, “/c”, args.toString()

        /* executing the command with environments set. */
        Process proc = Runtime.getRuntime().exec(command);
        /* handling the streams so that dead lock situation never occurs. */
        ProcessHandler inputStream = new ProcessHandler(proc.getInputStream(), “INPUT”);
        ProcessHandler errorStream = new ProcessHandler(proc.getErrorStream(), “ERROR”);
        /* start the stream threads */