Start other server with plugin?

Discussion in 'Plugin Development' started by Meatiex, Feb 9, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Meatiex

    I don't understand why the code below doesn't work...
    Code:
    Desktop.getDesktop().open(new File(System.getProperty("user.dir") + "\\other.bat"));
    It loads the current server, not doing much but saying port is in use....

    other.bat:
    Code:
    java -Xms3G -Xmx3G -jar Servers\other\bukkit.jar
    PAUSE
     
  2. Offline

    Skionz

    @Meatiex If you would like to launch CraftBukkit from a program I recommend using Runtime#exec(String). The String is a command which would probably be this 'java -Xms3G -Xmx3G -jar Servers\other\bukkit.jar.' This is probably the better way to go because you can read the output streams; it doesn't seem like you can with the Desktop class.
     
  3. Offline

    Meatiex

    Like this: ?
    Code:
    Runtime.getRuntime().exec("java -Xms3G -Xmx3G -jar " + "Servers/" + port + "/bukkit.jar");
    it didn't work....
     
    Last edited: Feb 9, 2015
  4. Offline

    Skionz

    @Meatiex Read the output streams and see if it is actually starting.
     
  5. Offline

    teej107

    @Meatiex The path to your spigot jar (spigot?!?!?! This belongs in Bukkit Alternatives!!!!) needs to be the absolute path of your jar file.
     
  6. Offline

    Meatiex

    @teej107
    Code:
    Runtime.getRuntime().exec("java -Xms3G -Xmx3G -jar " + System.getProperty("user.dir") + "/Servers/other/bukkit.jar");
    Still doesn't work...
    If its starting its not starting all the way, because I use this to check (The code below is tested and works)
    Code:
        private static boolean available(int port) {
            try (Socket ignored = new Socket("localhost", port)) {
                return false;
            } catch (IOException ignored) {
                return true;
            }
        }
     
  7. Offline

    Skionz

  8. Offline

    teej107

    @Meatiex Hard code it in rather than using the System property. Are you sure you know what the "user.dir" property returns?
     
  9. Offline

    Skionz

    Adding on to this, but are you sure you aren't supposed to be using 'user.home?'
     
  10. Offline

    teej107

Thread Status:
Not open for further replies.

Share This Page