Processbuilder exception CreateProcess When Java calls the executable file error=2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.