System.exit() problem

Discussion in 'Plugin Development' started by Codiction, Jul 5, 2013.

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

    Codiction

    So I have a wrapping tool that runs the bukkit server. It can turn on and off the bukkit server but if the bukkit server closes, bukkit calls a System.exit(0);

    I could prevent it from happening with a security exception but this creates an uncaught exception that totally breaks bukkit which prevents bukkit from starting up again.

    Using try catch doesn't work...
    Can anyone help me on this?

    PS: The last option is that each build of bukkit I modify the code a bit and repack it and publish my tool along with it. However this is not ideal.
     
  2. Offline

    Nitnelave

  3. Offline

    Codiction

  4. Offline

    John Cameron

    Code:
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all"); //Save all the players and world data.
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "stop"); //Stop the server, be warned plugins can't start it back up!
    And don't use System.exit(0);, the player data and world data will be lost!

    EDIT: Sorry didn't read it all, Anyways plugins can't start servers, only outside applications can.
     
  5. Offline

    Tirelessly


     
  6. Offline

    Codiction

    Thanks :) Yes, my application is not a plugin. It's an outside application that uses bukkit as library to run the main class inside that application. I will try your command things, thanks :)

    UPDATE: Sorry, the commands still close my application along with the server. When I use a security manager, it keeps my application running but it doesn't respond to further commands.

    I hate it that Bukkit uses System.exit(); ... It closes the entire JVM instead of just the thread it's on. Otherwise can someone tell me how I can recompile Bukkit? I could make a modified version but I can't get it to compile without errors. I tried using the bukkit library while compiling a class but it still doesn't work.

    Any tutorials or something?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page