Not executing UNIX command how expected

Discussion in 'Spigot Plugin Development' started by Swedz, Jun 26, 2016.

  1. So, I made a post a couple.. maybe few(or one? I don't know) hours ago, and it was about a similar topic on how to start a shell script (.sh) in java code. As that got solved, I managed to whip up this hunk of code that executes the right jar file I need, BUT it uses the server files from the server it's already in rather than the server the jar file is.
    Code (Text):
    Runtime rt = Runtime.getRuntime();
    String[] commands = {"java","-jar","/root/minecraft/PlayerServers/" + server + "/server.jar"};
    System.out.println("commands: " + new ArrayList<String>(Arrays.asList(commands)));
    Process proc = rt.exec(commands);
             
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
             
    String s = null;
    while((s = stdInput.readLine()) != null) {
       System.out.println(s);
    }
             
    while((s = stdError.readLine()) != null) {
       System.out.println(s);
    }
    This code just simply executes the server.jar at "/root/minecraft/PlayerServers/[the server name]/server.jar", and the issue is that it's not using the server files at "/root/minecraft/PlayerServers/[the server name]" as I want it to.

    What must I do to make it do this?

    Thanks in advance!
     
  2. This post isn't on the front page any more, and I really need help with this... I looked around to see the rules on bumping, but I couldn't find anything.. so...

    bump