0

Well, I have a c 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

1
  • 3
    Use a ProcessBuilder, not Runtime.exec() Commented Mar 15, 2014 at 2:47

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Please update your question with exact exception you're getting to help you.
Am not getting any exception .. the binary is supposed to cut comments and process the define statements as a preprocesser and then copy the new code to a temp file.. and its not doing that.. in terminal it works .. from JAVA no..
Try getting the InputStream from your Process and print in your Java program console. Your binary may be telling something why it can't do the job, also print the return value.
Actually it's not executing the binary at all
That's the reason I suggest to capture the process stream to know what is really getting executed.
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.