I'm trying to create a java application which starts a new terminal without using java -jar. I tried using several methods, but none of them have worked.
I need this to work on osx, I was able to make it on windwos
You have to call your shell as a program
Runtime runtime = Runtime.getRuntime();
String[] args = { "/bin/sh", "-c", " java -jar myjar.jar" };
final Process process = runtime.exec(args);
To respond to your specific request, this is my answer
1/ Create a shell script
For example call it loadJava.sh:
#!/bin/sh
java -jar path/to/jar/file.jar
2/ Call the shell script with this java code that open a terminal and run the shell script
Correct code for OSX is
Runtime.getRuntime().exec("/usr/bin/open -a Terminal /path/to/the/script");
java -jar
under the hood on Windows.without using java -jar
?