0

I'm just wandering. Is there a possibility to execute makefile.in using a Java command? Something like what you can do with Java and Ant.

Thanks

2
  • Do you mean execute make to run the Makefile (easy) or interpret the contents of the Makefile using only Java (would be a big deal) ? Commented Aug 18, 2011 at 1:42
  • I mean java code invoke make to run Makefile. I'm creating an event handler in Java to call make. Commented Aug 18, 2011 at 1:45

1 Answer 1

4

If I understand the question and comments correctly, then you want to use something like Runtime.exec(String).

String command = "make stuff" ; the make command you wish to run
String [] envp = { } ; if you want to set some environment variables
File dir = new File ( "/home/me/" ) ; // this is the directory where the Makefile is
Process proc = Runtime.getRuntime().exec(command,envp,dir);
proc.waitFor ( ) ;
Sign up to request clarification or add additional context in comments.

2 Comments

I did read some the reference say that you can used Runtime.exec(String). The problem is, I'm not sure what should be included in the bracket. Is it the make command?
Yes, the string is the command you want to run. You probably want a different version of the exec command that will let you specify the directory to run from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.