My main question is how can I make the command mentioned below work in java, The main problem in this command is it does not do script that I commanded it to execute; can someone help me make this apple script work in java?
I do not understand but for some reason the command:
osascript -e 'tell application "Terminal" to do script "cd /Users/benjaminsloutsky/eclipse-workspace/stack/Stack/StackProjects/Brother/build && cmake .. && cmake --build . && ./cmake-good"'
executes in the terminal, but whenever I try to run it in java using Runtime.getRuntime().exec() command it does not execute at all (it does not show me a new terminal window with code being execucted, but works in terminal). The whole point of this command is to show a new terminal with the output of the main.cpp file. This is my java code:
final String innerCommand =
"cd /Users/benjaminsloutsky/eclipse-workspace/stack/Stack/StackProjects/Brother/build && cmake .. && cmake --build . && ./cmake-good";
String[] comm = new String[] {
"/bin/bash", "-c",
"osascript -e 'tell application \"Terminal\" to do script \"" +
innerCommand + "\"'"
};
Runtime.getRuntime().exec(comm);
it does not run. Why is that and how could I fix this issue so my script could also run in javafx. The point of this command is to show a new terminal window and then run a script.
I thought that I am running multiple commands correctly as listed in my comm variable and I am executing the command with runtime.
Thank you in advance!
"\"'"to"\""in your Java code. The'should not be there.