How to get java getRuntime().exec() to run a command-line program with arguments?

后端 未结 4 1736
一生所求
一生所求 2020-12-14 21:34

I\'ve been trying to write a java program that uses the Runtime.getRuntime().exec() method to use the command-line to run an instance of the program \"tesseract

相关标签:
4条回答
  • 2020-12-14 21:56

    You are not capturing STDERR, so when errors occur you do not receive them from STDOUT (which you are capturing). Try:

    BufferedReader input = new BufferedReader(new InputStreamReader(
                   pr.getErrorStream()));
    
    0 讨论(0)
  • 2020-12-14 22:06

    another workaround is give complete installation path of file like /usr/local/Cellar/tesseract/3.02.02/bin/tesseract"

    0 讨论(0)
  • 2020-12-14 22:11

    Another workaround without having to recompile and deploy is using the old DOS style paths for e.g C:\Program Files would be C:\Progra~1. Of course this will be helpful only if you are reading the paths from a config file or DB and registry etc.

    0 讨论(0)
  • 2020-12-14 22:12

    well tesseract is external command so you do not need to use it with cmd. Add tesseract to environment variables. Use direct command as :

    String[] commands = {"tesseract", imageFilePath, outputFilePath };
    

    Exist status 1 means Incorrect function. See process exit status

    0 讨论(0)
提交回复
热议问题