Eclipse: Debug your Plugin

May 29, 2015
Eclipse: Debug your Plugin
  • Eclipse: Debug your Plugin

    Easy remote debugging with Eclipse



    1) Add Debugging statement to server script

    Add following statement to your server start script:
    Code (Text):
    -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

    The statements have to be inserted between java and -jar statement! This is important.

    So it should looks like:
    Code (Text):

    @echo off

    java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms512M -Xmx1024M -XX:MaxPermSize=128M -jar spigot.jar
    pause
     

    2) Open Debug Configuration in Eclipse

    Click on the arrow next to the "Debug" button and select Debug Configurations...
    [​IMG]

    3) Remote Debug Configuration

    Click on Remote Java Application and press the Add button on the top.
    [​IMG]

    On the right side you now see the debug configuration. Name your configuration and type 5005 in the Port textfield.
    Click Apply and Close.
    [​IMG]

    Note: You can change the port by editing the start script statement and the debug configuration.

    4) Restart your server

    With restarting your server the "debug server" will be started on port 5005.

    5) Set breakpoint and debug

    After that your are able to debug your plugin! Just set a breakpoint in the code, press Debug (your server has to be running) and select the new created Debug configuration in Eclipse. Now start minecraft, join your server and play! When you hit the breakpoint you will see the debug view in Eclipse.

    Careful: You have to set max-tick-time to a very high value (eg. 60000000) in your server config. So the server won't close after a short time at debugging.

    The user will be kicked out of the game really fast, because of a timeout! So you have to remember that!

    Thanks for reading ;) And start debug your Plugin.
  • Loading...
  • Loading...