Nullpointer exception when interact

Discussion in 'Spigot Plugin Development' started by R3XET, Nov 25, 2019.

  1. Don't print to see if something is null, use debugging instead. Debugging provides a lot more information.
  2. what a detailed and informative post. your explanation of debugging has made me question everything i thought i once knew.

    printing an object to see if its null or if its objects are null (depending on how well implemented #toString is) is debugging.. and provides the most information you can get regarding an object being null? i dont know what you think debugging is but printing null is just fine if #toString is fully implemented. if not, you just print the objects subobjects as well
  3. Strahan


    I assume he means the more advanced debugging that the development software is capable of. I've never tried that kind of debugging in Java, but when I debug stuff with Visual Studio I can add breakpoints and see the contents of all the variables in memory at a glance and get profiling information and all sorts of other goodies.
    • Agree Agree x 2
  4. I would assume that he's referring to using an IDE debugger as well. Depending on the OP's IDE, the steps may be slightly different. However there are a couple pages on the wiki that explain how to do it in both Eclipse and IntelliJ.

    That said though, if they don't want to go through the steps to set it up (as it can be a bit of a hassle to set it up on a live server), or if they simply can't (such as if they don't have a server where they can manage the jar launch settings), then printing to the console would be a solid choice for debugging as an alternative.
    #24 Ymerejliaf, Nov 28, 2019
    Last edited: Nov 28, 2019
  5. I mean debugging at runtime, IE adding breakpoints. You can just add a breakpoint without needing to add one or more print statements and it will also tell you a lot more information other than what the variable's value is. It may seem complicated, but it really isn't; IntelliJ provides a pretty simple debugging solution built-in.

    You can also perform "hotswaps" which is basically reloading the plugin/application at runtime without needing to issue any commands on the server, as long as no lines were added/removed.