0

I am trying to use Pandoc to create a PDF from a .md file in a Processing sketch using the method below:

    String[] command = {"pandoc", "-s", "-o", PDFname, "newFileName"};
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(command);

(Where PDFname is a string), but I am getting the following error:

java.io.IOException: Cannot run program "pandoc": error=2, No such file or directory

when I run pandoc from terminal I have not problems, so I am not sure what is going wrong here.

CodeMouse92
  • 6,840
  • 14
  • 73
  • 130
Mitchell Griest
  • 467
  • 1
  • 7
  • 21
  • Is "pandoc" at your system path (i.e at PATH variable)? – Carlitos Way Jun 01 '16 at 23:35
  • @CarlitosWay I am not sure, to be honest. I just installed it using homebrew and it is in /usr/local/Cellar – Mitchell Griest Jun 02 '16 at 00:07
  • @MGriest Step one would be to check your path. Can you run this on the command line without Processing? – Kevin Workman Jun 02 '16 at 00:31
  • @KevinWorkman yes, when I type the command I want to run by hand things work beautifully :/ – Mitchell Griest Jun 02 '16 at 00:46
  • What about permissions?? the command is executable/readable for any user?? – Carlitos Way Jun 02 '16 at 01:06
  • 1
    @CarlitosWay I believe so, I ran chmod u+x and I even went in by hand and made sure that every user could read and write. Changing the path to say `String command={/usr/local/Cellar/pandoc,-s,-o,PDFname,newFileName};` got rid of the permisison error and everything acts like it is working, but the new PDF file does not appear and when I search for it in Spotlight I can see that it exists but is completely empty... – Mitchell Griest Jun 02 '16 at 01:11
  • @MGriest, check this [link](http://stackoverflow.com/questions/37308809/compile-java-in-a-different-path-from-java/37309594#37309594) ... In there, I answer another command execution problem... may be tweaking your code, using my answer as guide, can help you (try to define the working dir using `builder.directory`)... Also, using the command as `/usr/local/Cellar/pandoc` makes me think the command is not reacheable... what are you using for running your JAVA app? – Carlitos Way Jun 02 '16 at 19:31

0 Answers0