Exit code 2 for dot [Ubuntu 14.04 LTS]

I am trying to spawn a graphviz dot process in Java. The process returns me an exit code 2. Unfortunately, I am not getting any insight into what the '2' means.

- The command line is ok - I tried executing the same on a terminal and it works perfectly.
- I have tried the verbose flag, but the process doesn't provide any verbose outputs

Can you please help with some insight into the error codes for dot and what they imply.

Many thanks in advance!

Can you provide the snippet

Can you provide the snippet of java code you are using to create the dot process?

Spawning dot returning 2

Thanks for the response. After some attempts I managed to get it to work. Here are my learnings for others encountering similar problem.

Background: I was porting a code working in Windows to Linux. The windows command construction was as follows:

StringBuffer command = new StringBuffer();
.append( dotExecFile.getAbsolutePath() )
.append(" -Tpng -o ")
.append(" -Kdot ")

Clearly this did not work because I need to use the exec( String, String, ... ) method. The proper code looks like this:

ArrayList<String> cmdParts = new ArrayList<String>() ;

cmdParts.add( dotExecFile.getAbsolutePath() ) ;
cmdParts.add( "-v" ) ;
cmdParts.add( "-Tpng" ) ;
cmdParts.add( "-o" ) ;
cmdParts.add( outputPath.getAbsolutePath() ) ;
cmdParts.add( "-Kdot" ) ;
cmdParts.add( dotPath.getAbsolutePath() ) ;

The part where I was struck was that I was quoting the paths, which is not required if I am using the String, ... method. The above code works like a charm.



Good. I am glad you worked it

Good. I am glad you worked it out. If you have any other issues, let us know.

Recent comments