简体   繁体   中英

Execute linux command line within JAVA

Well, I have ac program that is stored in /bin, I want to execute the program from a JAVA GUI but it's not working..

I tried

Process p = Runtime.getRuntime().exec("lexical " + nameOfFile+"/Source.cpp " + nameOfFile+"temp.c");
p.waitFor();

nameOfFile holds the absolute path for the workspace directory, lexical is my c program

You have to provide the absolute path to the binary you're trying to execute from Java. Java won't pick up the application from your Linux $PATH.

Seems like the problem was the multiple parameters I was sending.. I had to put them in a string[] command and the execute..

Thanks a lot for your help and time

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM