When Java calls other applications, there may be no problem with windows, but going to Linux will report such errors, such as having a design file operation that will report FileNotFoundException, and so on (code below):
1 New Processbuilder (); 2 Builder.command (ffmpeg-i/data/download_video/20160425/20160425235938929164582_1.flv-y-vcodec libx264-vpre Ultrafast-vpre baseline-cqp 28-coder 0-refs 3-deblockalpha 1-deblockbeta-1-me_method umh-subq 9-me_range 32-tre Llis 2-chromaoffset-2-nr 0-b_strategy 1-bframebias 0-directpred 3-g 250-i_qfactor 1.3-b_qfactor 1.4-flags2 +bpyr Amid+wpred+mixed_refs+8x8dct-acodec libfaac-s 640*360-b 532000-ab 58000-r 15-pass 1/data/video/output/20160425/ 20160425235938929164582_1_06400360.mp4); 3 builder.start ();
4 .....
Cause: An unrecognized instruction error may occur if there are spaces between different operating system directives.
WORKAROUND: There are spaces in the instruction need to be separated by a different string, the instruction is split with a space, through an array of instructions to pass the value, using the API:
Public processbuilder command (String ... command)
Refer to the Processbuilder class description:
Constructs a process builder with the specified operating system program and arguments. This was a convenience constructor that sets the process Builder's command to a string list containing the same strings as commandthe array, in the same order. It is not checked whether command corresponds to a valid operating system command.
-
Parameters:
-
Command A string array containing
the program and its arguments
Processbuilder exception CreateProcess When Java calls the executable file error=2