I'm trying to create an executable .jar that re-opens itself in Mac's Terminal console. (for the sake of having a user interface to enter commands into the program)
// if program is not open in Terminal:
Runtime.getRuntime().exec("java -jar \"" + path + "\" isInConsole");
System.exit(0);
This code executes the command successfully but seamlessly so I don't get the console UI. How can I make it open a visible Terminal window and execute a command in it?
EDIT: I managed to open the Terminal, but still need to figure out how to run the java -jar ...
command in it.
This works:
String arg = "cd /Users/potato/Desktop";
Runtime.getRuntime().exec("open -a Terminal --args " + arg);
But this doesn't work:
String arg = "java -jar /Users/potato/Desktop/test.jar isInConsole";
Runtime.getRuntime().exec("open -a Terminal --args " + arg);