Runtime.getRuntime()。exec()问题

时间:2015-04-25 15:55:18

标签: java process exec gdal

我试图从Java代码运行另一个程序:

String[] command = {"gdal_polygonize.py", "/home/user/myoldfiles/proceeded.tiff", "-mask", "/home/user/myoldfiles/biomass_02.08.14.tif", "-f", "'ESRI Shapefile'", "/home/user/myoldfiles/proceeded.shp", "DN"};
Process p = Runtime.getRuntime().exec(command);

我没有在/ home / user / myoldfiles /中创建的文件proceededed.shp 使用BufferedReader获得的命令输出如下所示:

Creating output /home/user/myoldfiles/proceeded.shp of format 'ESRI Shapefile'.

当我在终端(Ubuntu)中运行下一个命令时

 gdal_polygonize.py '/home/user/myoldfiles/proceeded.tiff' -mask '/home/user/myoldfiles/biomass_02.08.14.tif' -f 'ESRI Shapefile' '/home/user/myoldfiles/proceeded.shp'

打印

Creating output /home/user/myoldfiles/proceeded.shp of format ESRI Shapefile.
0...10...20...30...40...50...60...70...80...90...100 - done.

并成功创建了proceeded.shp文件。我在Java代码中做错了什么?

1 个答案:

答案 0 :(得分:0)

感谢大家的帮助!我找到了解决方案here。问题是'ESRI Shapefile'中的单引号,我刚删除它们,现在一切正常!