0

Below is the portion that is throwing the error

File dir = fcd.getSelectedFile(); // file directory in which to compile all code
String[] cmdarray = {"javac *.java"};
try {
    Process process = Runtime.getRuntime().exec(cmdarray,null,dir);                 
    }                   
catch (IOException ex) {
    ex.printStackTrace();
    }

I'd prefer to use the wildcard instead of recursing through an ls or dir of the files in the pwd before running the actual command. If it's not possible to use *, is there a way to specify the file extension for all the files in the pwd?

  • Does this answer your question? [Why does Runtime.exec(String) work for some but not all commands?](https://stackoverflow.com/questions/31776546/why-does-runtime-execstring-work-for-some-but-not-all-commands) – Kaan Jul 30 '22 at 03:39

1 Answers1

0

Welp, that's what I get for not doing more testing, Why does Runtime.exec(String) work for some but not all commands? answers it, the command and argument wasn't properly split, that's why exec(String[] cmdarray, String[] envp, File dir) takes an array of String for it's command array; one string like "javac .java" would confuse it and maybe be read as a command even though "javac" is the command and ".java" is the argument.

After making cmdarray = {"javac","*.java"};, it worked.