Instead of using a .bat file, how the code can be built for java program for compiling and executing a list of java programs.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On
Runtime.execThough perhaps not the most ideal solution, you an execute a shell command as a separate
ProcessusingRuntime.getRuntime().exec(someCommand). There are also overloads that takes parameters as aString[].This is not an easy solution. Managing a concurrent
Processand preventing a deadlock etc is not trivial.Related questions
On draining
ProcessstreamsGenerally you can’t just
waitFor()aProcessto terminate; you must also drain its I/O streams to prevent deadlock.From the API:
Related questions
On the Java 6 Compiler API
One option to compiling a Java source code within Java is to use the Java 6 Compiler API. This requires a JDK to be installed (not just a JRE).
See also
interface JavaCompilerfrompackage javax.toolsRelated questions