Debugging in IntelliJ the Intelligent Way! ;) w/ JRebel

Discussion in 'Resources' started by Favorlock, Mar 6, 2014.

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

    Favorlock

    I put together a simple tutorial that explains the proper way to debug bukkit plugins with an IDE. In this tutorial I explain how to debug utilize the debug functionality of IntelliJ to it's fullest and avoiding the plugin class loader issue that you get with some plugins when using IntelliJ's application configurations. If you have any questions please feel free to ask.

    Create a working directory with a bukkit server jar and bat file. Your working directory should look as follows

    [​IMG]
    Your bat file should look similar to the following:
    Code:
    java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms256M -Xmx1024M -XX:MaxPermSize=128M -jar ./server.jar
    pause
    In intellij go to the “Run/Debug Configurations” menu and click the green plus and select “Remote”. You can leave the settings as default and providing your bat file looks like the image shown above you have already completed setting up your remote debug server.

    Go to Settings -> External Tolls and click the green plus to add a new tool. The default options should be fine, however, you do need to set the program as the bat file you created and the working directory to the root directory that your bat file and server jar are in. Your tool should look similar to:

    [​IMG]

    Once you have all of that configured simply set your remote debug configuration as your current configuration and select debug. Intellij should open a new window attached to your remote debug instance. Be sure to run the external tool by going to Tools and selecting the tool you created. Alternatively you can run the bat file manually from your working directory. You can now use IntelliJ’s debug features to their fullest.


    Using JRebel In IntelliJ:

    First of all, you will need to go to my.jrebel.com and log in using Facebook or Twitter. You will then have the opportunity to subscribe to JRebel Social which will grant a free non-commerical license.

    In IntelliJ go to Settings -> Plugins -> Browse Repositories and search for JRebel Plugin. Install the plugin and restart your IDE. You should be greeted with an activation menu that looks like so:

    [​IMG]

    If not, go to Settings -> JRebel and select Open Activation Dialogue in the top right. Copy and paste the license that you received and click ok.

    You will need to download jrebel.jar from the JRebel website or locate the JRebel jar that was downloaded when installing the IntelliJ plugin and copy it to your working directory. Alternatively you can use the absolute path of the jar if you do not wish to copy it to your working directory. You should be able to find it by going to Settings and clicking the arrow next to JRebel and selecting Advanced.

    [​IMG]

    Create or modify a bat script to contain the following configuration:
    Code:
    java -javaagent:jrebel.jar -Drebel.remoting_plugin=true -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xms256M -Xmx1024M -XX:MaxPermSize=128M -jar ./server.jar
    pause
    If you use Maven then you need to add the following to your pom.xml:
    Code:
    <plugin>
        <groupId>org.zeroturnaround</groupId>
        <artifactId>jrebel-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>generate-rebel-xml</id>
                <phase>process-resources</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    If you use Gradle then you need to add the following to your build.gradle:
    Code:
    apply plugin: 'rebel'
     
    buildscript {
        repositories {
            mavenCentral()
            maven {
                name = "zt-public-snapshots"
                url = "http://repos.zeroturnaround.com/nexus/content/groups/zt-public"
            }
        }
     
        dependencies {
            classpath group: 'org.zeroturnaround', name: 'gradle-jrebel-plugin', version: '1.1.2'
        }
    }
    Congratulation, you are now ready to use JRebel with IntelliJ! Note that if you are using Gradle you will need to run the task "generateRebel" before you run the build task. Now you can run your build script and copy the jar to your plugin directory and then run your remote debug configuration. Start Minecraft and log into your server, add some classes and methods to your plugin, rebuild with maven/gradle (no need to move the jar to your plugin directory again), and see the results for yourself by testing your features in game!

    Thank you to tips48 for this wonderful tutorial explaining how to use JRebel with Eclipse and maven.
     
  2. Now just put some JRebel juice in there and we're good :)
     
    Favorlock, CaptainBern and Bart like this.
  3. kumpelblase2 I've never worked with JRebel, mind if I pm you?
     
  4. CaptainBern well, I never said anyone would need permission to talk to me so :)
     
    CaptainBern likes this.
  5. Offline

    Favorlock


    What I'm curious about is whether they still support the JRebel Social. As far as I can see they don't provide free non-commercial use of JRebel anymore. :\
     
  6. Favorlock eeewwww :S But I just looked at their site and don't see it either :/ Maybe they just keep they already existing ones active and don't let new ones in?

    EDIT: Well it should still exists, it's just not present on their landing page.
     
  7. Offline

    Favorlock

    kumpelblase2 Yeah, I'm not sure as I can find the topic that explains it, but it just doesn't match with the latest versions of JRebel.
     
  8. Favorlock I can still login and see my license code, but I can't see any plans that I could subscribe so to speak.

    EDIT: Just looked at their FAQ page, doesn't mention any free plan or anything which would come close to that.
    EDIT2: Hearing from other sources that it still exists. Might need to search for the old thread in this section and use that link.
    EDIT3: Link mentioned here should still work.
     
  9. Offline

    Favorlock

    kumpelblase2

    Taking a look now. :)

    EDIT1: Going to update the topic in a bit. :D
    EDIT2: All done! I think I covered everything needed.
     
  10. Offline

    DeejayArroba

    TheGamersCave likes this.
  11. Offline

    TheGamersCave

Thread Status:
Not open for further replies.

Share This Page