Wednesday, June 17, 2015

Use Intellij IDEA to make your debugging life easy

Here is a simple tip which will make it easy to debug codes and try out new things in Intellij IDEA

First thing is we can use Intellij IDEA to remote debug codes which runs in servers. But this post is not about configuring remote debugging in Intellij IDEA.

Lets take an example - We use WSO2 server, say WSO2-AS. We are remote debugging an application we deployed in AS for a issue with IDEA. Say we find the solution. Normal procedure is to implement the solution, build it, and redeploy it. But this may take considerable amount of time. But using Intellij Idea, we can reduce this burden. What we have to do is attach IDEA remote debugger to AS, implement the required code and then compile that code within IDEA. After compiling the code IDEA will automatically reloads the attached JVM's class instance with newly compiled code.

This makes life easy, as we don't need to rebuild and redeploy codes to apply the changes.

Bellow are the steps listed down again for clarity

1) Attach IDEA remote debugger to the server
2) Do the required code change in the source
3) Compile the code within IDEA (You can do this by right clicking on the class and select "compile")

And that's it, IDEA will reload the attached JVM with newly changed class.

Notes -
1) We can't use this method to reload big changes done on the source. Say like implementing new class, adding new dependency etc
2) This method will be very much useful in scenarios where we even have to restart the servers to apply changes. Say debugging component issues in wso2 products.
3) This reload only affects current running JVM instance. If we restart the server, these changes will be gone as server will reload original classes from bundles

1 comment :

Unknown said...


This saves days.,.,.

Thanks boss