0

I am trying to call the sccmap command from GraphViz using Java.

        String command = "/usr/bin/sccmap -S /home/paperclip/Desktop/graph.dot > /home/paperclip/Desktop/scc.dot";
        try {
            Runtime rt = Runtime.getRuntime();
            Process p = rt.exec(command);
            System.out.println("Process exited with code = " + p.waitFor());
            java.io.InputStream is = p.getInputStream();
            java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is));
            String s = null;
            while ((s = reader.readLine()) != null) {
                System.out.println(s);
            }
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

The output for this snippet of code is:

Process exited with code = 0

The sccmap function is supposed to output a dot file in the location that I have specified. However, it doesn't work like I expected. Even though the exitValue was given as 0, the dot file was not created.

I tried using the command manually in Terminal and it works perfectly. I also tried using other commands such as "ls" and it works too. Why does this code not work for "sccmap"?

I also searched for some Java APIs for GraphViz such as the jGraphViz (http://jgraphviz.sourceforge.net/) and graphviz-java-api at (http://www.loria.fr/~szathmar/off/projects/java/GraphVizAPI/index.php), but they don't seem to work for me.

FYI I am on Ubuntu 11.10 and GraphViz is already installed.

Thanks!

paperclip
  • 650
  • 2
  • 8
  • 23

1 Answers1

3

> is interpreted by the shell (it's a stream redirect), it's not an argument to the application. There is no shell in this situation.

Try /usr/bin/sccmap -S -o /home/paperclip/Desktop/scc.dot /home/paperclip/Desktop/graph.dot instead.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680