开发者

I am getting some problem while executing binary executable file using Java code

开发者 https://www.devze.com 2023-03-03 12:49 出处:网络
I am getting some problem while executing binary executable file using Java code. My Executable file is running perfectly on Terminal(Linux os) using following command

I am getting some problem while executing binary executable file using Java code.

My Executable file is running perfectly on Terminal(Linux os) using following command

./ab0818 < ab0818.challenge

where "ab0818" is executable file and "ab0818.challenge" is input file.

I will get 0 exit code after running this command in terminal

My Code is Bellow.

System.out.println("Running the batch script");

Process p = Runtime.getRuntime().exec("./ab0818 < ab0818.challenge");
p.waitFor();
System.out.println("is.read() = "+p.exitValue());   

when I am run my code it will never come out of wait(waitFor()) process and my program never terminates.

My question is there any alternative way to execute command using java code or is there any modification needed in my开发者_如何转开发 code.

Thanks in Advance, -Viraj


Java doesn't know about the Linux shell's redirection operator "<".

You could try:

...exec("bash -c './ab0818 < ab0818.challenge'")

You might also want to look at http://download.oracle.com/javase/6/docs/api/java/lang/ProcessBuilder.html

0

精彩评论

暂无评论...
验证码 换一张
取 消