Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
880 views
in Technique[技术] by (71.8m points)

windows - Possible causes of java.io.IOException: CreateProcess error=5

What kind of problem(s) could cause Java's ProcessBuilder.start method to return an IOException with a note saying error=5?

Specifically, we've seen a remote customer system running some Java code along the lines of...

ProcessBuilder pb = new ProcessBuilder(cmdArray);
pb.redirectErrorStream(true);
Process p = pb.start();

...throw exceptions like this...

java.io.IOException: CreateProcess: C:exampleexample.exe argument1 argument2 error=5
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at example_code_above

We have confirmed that the command noted in the exception, "C:exampleexample.exe argument1 argument2" can be run successfully by hand via cmd.exe, so we are confident the command itself is not broken.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

error=5 means one of:

1) file is not executable
2) file is not accessible

EDIT: wont throw exception
3) the command (example.exe) exits with exit code 5


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...