I'm writing a library to cover WMctrl shell program. I have problem with resizing windows:
String command = "wmctrl -r \"Calculator\" -e 0,100,100,500,500";
System.out.println(command);
String output = this.bashCommandExecutor.execute(command);
System.out.println(output);
This doesn't work - output variable is empty. But when I copy-paste wmctrl -r "Calculator" -e 0,100,100,500,500 to the Terminal it works properly.
Other commands like "wmctrl -d" and "wmctrl -l" work in this.bashCommandExecutor.execute() method.
This method looks like this:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BashCommandExecutor
{
String execute(String bashCommand)
{
Process p = null;
try {
p = Runtime.getRuntime().exec(bashCommand);
p.waitFor();
}
catch (InterruptedException | IOException e) {
e.printStackTrace();
}
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream())
);
String line = "";
StringBuilder sb = new StringBuilder();
try {
while ((line = reader.readLine())!= null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
}
Why does resizing work in command line, but doesn't work in Java app?