I have a java application and from that application I want to be able to run new applications. While the concept is the same, I'm using this in a Minecraft environment where I want to have one application be able to run other Minecraft servers whenever I specify so in the first application.
I'm trying to run the startup shell script but whenever I do I simply get the error .
Note that I am perfectly able to run the script on my computer by "double clicking it", the shell script works, Java application starts up, and I can join the game server and play without any problems.
I've also tried running the jar application directly from the code, but then I get either or (using ProcessBuilder), even though I've set all the computer to have all permissions regarding reading and writing the file.
This is my code for running the shell script:
// Starts the server by running the script
File startScript = new File("C:\\Users\\{MYUSER}\\Desktop\\{PROJECTNAME_FOLDER}\\Network\\prison-spawn-2\\start.bat");
// Run the process
try {
Process process = Runtime.getRuntime().exec("cmd /c start " + startScript.getCanonicalPath());
int exitVal = process.waitFor();
if (exitVal == 0) {
System.out.println("Success!");
}
} catch (Exception exception) {
exception.printStackTrace();
}
echo "Starting server..."
java -jar C:\Users\{MYUSER}\Desktop\{PROJECTNAME_FOLDER}\Network\prison-spawn-2\server.jar nogui
