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

浪子不回头ぞ 提交于 2019-12-03 02:55:33

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

hkd93

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()));
user1382115

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!