I am trying to use Java's
Process p = Runtime.getRuntime().exec(command);
to compile .java files in other folder, but it does not work.
My Main.class is in folder a, and all .java files are in folder a/test.
Main.class is :
public class Main{
public static void main( String[] args )
throws IOException,InterruptedException{
String line ="";
String command = "javac test/*.java";
Process pro = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(
new InputStreamReader( pro.getInputStream()));
while ((line = in.readLine()) != null) {
System.out.println(line);
}
BufferedReader er = new BufferedReader(
new InputStreamReader( pro.getErrorStream()));
while ((line = er.readLine()) != null) {
System.out.println(line);
}
}
}
And the error stream shows:
javac: file not found: test/*.java
Why does this happen? There are some java file in folder test