Monday, February 16, 2015

JDebug - A Java Debugging plugin for Sublime Text

Debugging is a painful art. The programmers(coders) know about it. Even perfectly written code may misbehave sometimes and it is difficult to identify the piece of code causing the issue just by log statements. So the only possible way to identify the issue is to do step by step debugging of the code dynamically. There are so many debugging tools available for Java, some are standalone and few are integrated within the IDE like Eclipse. In this article, I will show you how to debug java codes remotely using JDebug in Sublime Text.

Setting up Sublime Text JDebug plugin can be installed using Package Control or manually. I will show you how to install JDebug plugin using Package Control. If you haven’t install the Package Control, you can install packages by installing package control.
Once you have the package control installed, you should start Sublime Text. Open up the command palette from the Preferences --> Package Control menu and search for “Install Package”.


Now you can search for any package you like. In our case, we are going to search for the package “JDebug”.


Setting up App Server (Weblogic/Tomcat/any other) in debug mode
Pass -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 as JVM argument to server startup command. You can change the debug port from 8000 to anything you prefer.
Tomcat
Add/update the JAVA_OPTS env variable in catalina.bat or catalina.sh set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
Weblogic
Add/update the SAVE_JAVA_OPTIONS env variable in catalina.bat or catalina.sh set SAVE_JAVA_OPTIONS=%JAVA_OPTIONS% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Setting up JDebug Setting up JDebug is very simple as it has only few settings to start with. You can copy and paste the default settings into user settings and update the following settings based on your environment.


  • workingdir -     You need to set your current project directory like c:/worksapce/TestService (Windows) or /home/user/abc/workspace/TestService (Linux or Ubuntu)
  • commandline -     Set the jdb command with arguments. If JDK/bin is not in your environment PATH then you need to specify full path to the jdb command. Also change the hostname and port in which the java application service is running and listening.
  • sourcepath -     The path to the source file with in the project. For ant project it usually /src/ and for maven usually /src/main/java.



Breakpoints Ready to set the breakpoint?. Breakpoints are the way to inform the jvm to halt the execution at a particular point (line number or method in a class). When the execution halts, the application variables can be inspected.
Add a breakpoint using 'Toggle Breakpoint' menu option from context menu. Context menu can be accessible using right click. A circle icon will be placed on the line number gutter when a breakpoint is added


When the jvm hits the breakpoint during the execution, the gutter icon will be changed to 'pointer' to indicate that the breakpoint is hit.

Inspect Variables

Variables & expressions can be inspected using inline popup. Click on the variable or highlight the expression to evaluate/inspect inline.



Watch Expressions Expressions can be evaluated using the 'Add Expression' context menu. You can enter any valid expression to evaluate.

Enter the Expression

JDebug Variables It is interesting to watch the variables in the 'JDebug Variables' window. If a variable is complex object it will be displayed with '+' icon on gutter. These variables can be expanded further to get the additional details using 'Expand' context menu. The 'Expand' context menu will be enabled only in 'JDebug' variables window.

How to Continue?

The application execution can be continued using one of the following menu options
  • Step Over Continue execution to next line
  • Step Into Continue the execution into a method call
  • Step Out Step out of the current method and continue
  • Continue Continue to next breakpoint or till completion

91 comments:

  1. This is awesome. As always great work Senthil

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. You could give a real example of how to set up, I am newbie in using "Sublime Text"!
    I have only one working folder in c: \ JavaApp \. Alli am making practice and need to use jDebug to see how they change the values of the variables.
    Thank You.

    ReplyDelete
  4. Java developers will find this kit handy as it lets you test the compatibility of your projects with reference to Java specifications. Sun open-source, can now have access to their Compatibility Kit related to Java development technology.
    java

    ReplyDelete
    Replies
    1. I have read your blog its very attractive and impressive. I like it your blog.

      Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

      Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai JavaEE Training in Chennai Java EE Training in Chennai

      Delete
  5. How do you determine the hostname and port in the commandline setting?

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training

      Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai Java Online Training Java Online Training

      Delete
  7. Hibernate and spring are the frameworks of Java. A java developer should be well aware of these frameworks in order to master the technology and work efficeiently.
    spring training in chennai | hibernate training in chennai
    FITA Academy reviews

    ReplyDelete
  8. Java is the most robust secured and multi threaded programming language which is the reason why most the the developers go for java. A single java code can be used for various platforms.
    JAVA training in chennai | java training institutes in chennai | FITA Academy Chennai

    ReplyDelete
  9. The best thing about HTML5 is that it allows the developers to embed the video files, audio files, and high quality graphics without any third party applications.
    html5 training in chennai | html5 training institutes in chennai | FITA Academy reviews

    ReplyDelete
  10. Hi, actually I'am new to angularJs and infact I'am learning angularjs with online training. I'am having doubt, if you could solve the doubt for me that would be very helpful. The doubt is, how can I reset a “$timeout”, and disable a “$watch()”?
    Regards,
    angularjs training in Chennai | angularjs training | angularjs training Chennai

    ReplyDelete
  11. The main thing which i like about web designing is that it needs creativity and we need to work differently acccording to our clients need this needs a creativity and innovation.
    web designing course in chennai | web designing training in chennai | web designing courses in chennai

    ReplyDelete
  12. Oracle database management system is a very secure and reliable platform for storing database and secured information.Due its reliable and trustworthy factor oracle DBA is famous all around the globe and is prefered by many large MNC which are using database management system.
    oracle training in Chennai | oracle dba training in chennai | oracle training institutes in chennai

    ReplyDelete
  13. I really similar to my spouse and i have bookmarked the internet blog. The item seems to be able to possibly be very interesting. it is advisable to keep uploading added with future with regard to all involving us. Contact Page

    ReplyDelete
  14. Spring is an open source framework which is mainly used in java applications that can be deployed in standalone platform.
    spring training in chennai | spring course in chennai

    ReplyDelete
  15. Excellent post. Keep sharing such a useful post.

    SEO Services in Chennai

    ReplyDelete
  16. The blog you presented was very nice and interesting which helped me to get update on the recent technologies.
    Angularjs training in chennai | Angularjs course in Chennai

    ReplyDelete
  17. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info! , Regards, servicenow training in hyderabad

    ReplyDelete
  18. Your blog content is really very informative and unique. Thanks for sharing the valuable blog. Core Java Training | Dot Net Training

    ReplyDelete
  19. Sublime Text and setting up its break up point is really a dedious one to go through, You made it simple to understand. Thanks for the post. Good Work
    AngularJS Training Institute in Chennai | Best AngularJS Training in Chennai | AngularJS training and placement

    ReplyDelete
  20. how can i determine the hostname and port for commandline?

    ReplyDelete
    Replies
    1. The hostname is where your application server like tomcat, jboss, weblogic or webshpere is running. The port is specify as debug port in the application server startup command

      Delete
  21. Much obliged to you for magnificent data I was looking for this information for my main goal.
    Regards,AngularJS Training in Chennai

    ReplyDelete
  22. Nice information about java debugging plugin Thanks for sharing it
    Java Training in Chennai

    ReplyDelete
  23. This article provides the information about Java its key features and scope for java professionals. This information is really helpful me to know more about Java programming language. Java Training in Chennai | Java Training | Java Course in Chennai

    ReplyDelete
  24. This is my first visit to your blog, your post made productive reading, thank you. Java Training in Chennai

    ReplyDelete
  25. Attractive blog post! I should read from some useful news for this blog section, It 's a great content Keep it useful sharing.
    Selenium Training in Chennai
    selenium training institute in chennai
    best angularjs training in chennai
    angularjs training institute in chennai

    ReplyDelete
  26. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharng this information,this is useful to me...
    Android training in chennai
    Ios training in chennai

    ReplyDelete
  27. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Web Design Company
    Web Development Company

    ReplyDelete
  28. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog


    Core Java Online Training

    ReplyDelete
  29. Really very informative post you shared here. Keep sharing this type of informative blog. If anyone wants to become a Java professional learn Java Training in Bangalore. Nowadays Java has tons of job opportunities for all professionals.

    ReplyDelete
  30. I believe I set it up all correctly, and I can see the program waiting for the me to take the next step or release the breakpoint, but I never get the 'arrow icon' on my breakpoint through sublime.
    If I tell JDebug to stop debugging the program continues happily. Can somebody help me out?

    ReplyDelete
  31. This article provides the information about Java its key features and scope for java professionals. This information is really helpful me to know more about Java programming language. Anybody want to build your own website

    White Label Website Builder

    ReplyDelete
  32. Thanks for your informative blog!!! Your article helped me to understand the future of Core Java programming language. Keep on updating your with such awesome information.

    White Label Website Builder

    ReplyDelete
  33. SV Soft Solutions is offering best Java online training with 100% job assistance and high quality training facilities and well expert faculty .
    to Register you free demo please visit Java Online Training Institute with Job Support

    ReplyDelete
  34. If you are looking for spring hibernate training institute in chennai then candid training is the best place to learn.

    Candid gives you best in class spring hibernate training with high quality and post training support, We provide you free demo session and candid promises the permanent trainer throughout your session and focus on more practical.

    candid training

    ReplyDelete
  35. I'm trying to setup Jdebugger with Grails project. Jdebug says that jdb is attached, but Grails keeps waiting for more commands (a 'run' maybe?). Can you give any help for Grails setup? I've set following with no success:

    {
    "workingdir": "Code/git/project/",
    "commandline": "jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=5005 -launch",
    "sourcepath": "/target/work/",
    "debug": true
    }

    ReplyDelete
    Replies
    1. Hi Niko

      My settings are below and using Windows OS. TestService is my project directory which has the 'src' directory. You need to specify the base working directory and source_path_prefix if you have any.

      "workingdir": "C:/Workspace/TestService",
      "source_path_prefix": "/src/",

      In simple workingdir + source_path_prefix should point to the path where you have the java file or base package name

      My Project Structure (Windows)
      C:\
      .......Workspace
      ............TestService
      ..................src
      ......................com
      ...........................jdebug
      .................................demo
      ......................................servlet
      ............................................JDebugTestServlet.java

      Delete
    2. Thanks for helping. I still cannot get it to work. If I start my Grails app with grails 'run-app --debug-fork', it waits for jdb to connect. When I connect jdb using 'jdb -attach 5005' or 'jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=5005', the grails app continues and I can start using jdb aswell - All good! However, if I set those same commands to Jdebug commandline-config, the grails app keeps waiting for something. Jdebug continue-command in command menu is passive. In Jdebug console it says

      ## Attaching JDB... ##
      ## JDB Attached ##
      -> stop at ani.Code.git.bfw-forms.src.bfw-forms.grails-app.services.com.bcbmedical.bfw.forms.FormDataService.groovy:44

      Do you have any more ideas I could try to get it to work?

      Delete
    3. I'm trying to get this to work again. I'm trying with a Grails 3.x project now. Tried with the both, Gradle and Grails. It keeps waiting for something.

      jDebug Console:
      ## Attaching JDB... ##
      ## JDB Attached ##
      -> stop at .makelani.Code.git.the-project.grails-app.controllers.com.template.ListController.groovy:28


      jDebug conf:
      {
      "workingdir": "/Users/makelani/Code/git/the-project/",
      "source_path_prefix": "/build/",
      "commandline": "jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=5005",
      "debug": true
      }

      terminal (waiting for something):
      git:(feature/grails_3x) ./gradlew -Dorg.gradle.debug=true bootRun
      Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details

      > Starting Daemon


      Project dir:
      the-project
      --.gradle
      --build
      --gradle
      --grails-app
      --src

      Delete
    4. I found following from the Sublime text console:

      Packages/JDebug/icons/collapsed.png
      waiting until JDB is loaded...
      JDB is now loaded!
      jdb_stdin: stop at .makelani.Code.git.the-project.grails-app.controllers.com.template.ListController.groovy:28
      Traceback (most recent call last):
      File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1036, in run_
      return self.run()
      File "/Users/makelani/Library/Application Support/Sublime Text 3/Installed Packages/JDebug.sublime-package/JDebug.py", line 817, in run
      File "/Users/makelani/Library/Application Support/Sublime Text 3/Installed Packages/JDebug.sublime-package/JDebug.py", line 472, in sync_breakpoints
      File "/Users/makelani/Library/Application Support/Sublime Text 3/Installed Packages/JDebug.sublime-package/JDebug.py", line 396, in add
      File "/Users/makelani/Library/Application Support/Sublime Text 3/Installed Packages/JDebug.sublime-package/JDebug.py", line 557, in run_cmd
      ValueError: Command "stop at .makelani.Code.git.the-project.grails-app.controllers.com.template.ListController.groovy:28
      " took longer than 50 seconds to perform?

      Delete
  36. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    Best Java Training Institute Chennai


    Java Training Institute Bangalore


    ReplyDelete
  37. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…

    software testing course in chennai

    ReplyDelete
  38. Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
    big-data-hadoop-training-institute-in-bangalore

    ReplyDelete
  39. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    Hadoop Training in Chennai

    ReplyDelete
  40. Ciitnoida provides Core and java training institute in

    noida
    . We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-

    oriented, java training in noida , class-based build

    of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an

    all-time high not just in India but foreign countries too.

    By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13

    years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best

    Java training in Noida.

    java training institute in noida
    java training in noida
    best java training institute in noida
    java coaching in noida
    java institute in noida

    ReplyDelete
  41. The use and interface of Audio to text message is extremely easy to use and simple, making it usable for every single versatile client. It makes forming messages simple.computer voice generator

    ReplyDelete
  42. nice and interesting article about "A Java Debugging plugin for Sublime Text" thanks for sharing.
    Data Science Training in Chennai

    ReplyDelete
  43. nice article very interesting thanks for sharing.

    Selenium Training in Chennai

    ReplyDelete
  44. This comment has been removed by the author.

    ReplyDelete
  45. thanks for sharing..hope you will share more article like this
    Python Training in Chennai

    ReplyDelete
  46. Nice and usefull contents. thanks for sharing. expecting much in the future.

    RPA Training in Chennai

    ReplyDelete
  47. This was an nice and amazing and the given contents were very useful and the precision has given here is good.hadoop training in chennai

    ReplyDelete

  48. This was an nice and amazing and the given contents were very useful and the precision has given here is good.
    Bigdata Analytics Training in Chennai

    ReplyDelete
  49. Appreciating the persistence you put into your blog and detailed information you provide

    selenium training in chennai
    aws training in chennai

    ReplyDelete
  50. I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favourites blog site list and will be checking back soon.

    java training in chennai | java training in bangalore

    java online training | java training in pune

    ReplyDelete

  51. I've been surfing on the web more than 3 hours today, yet I never found any stupefying article like yours. It's imperatively worth for me. As I would see it, if all web proprietors and bloggers made confusing substance as you did, the net will be in a general sense more profitable than at whatever point in late memory.

    Digital Marketing Training in Mumbai

    Six Sigma Training in Dubai

    Six Sigma Abu Dhabi

    ReplyDelete
  52. This comment has been removed by the author.

    ReplyDelete
  53. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in Chennai | rpa training in pune

    rpa training in tambaram | rpa training in sholinganallur

    rpa training in Chennai | rpa training in velachery

    rpa online training | rpa training in bangalore

    ReplyDelete
  54. I think this is a great site to post and I have read most of contents and I found it useful for my Career .Thanks for the useful information. For any information or Queries Comment like and share it.

    PMP Training Abu Dhabi

    GDPR Training in Hyderabad

    Digital Marketing Training in Hyderabad


    six sigma Training Pune

    ReplyDelete
  55. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great

    content of different kinds of the valuable information's.

    angularjs Training in bangalore

    angularjs Training in btm

    angularjs Training in electronic-city

    angularjs Training in online

    angularjs Training in marathahalli

    ReplyDelete
  56. I have read your blog and I gathered some needful information from your blog. Keep update your blog. Waiting for your next update. Java Training in Chennai | Python Training in Chennai

    ReplyDelete
  57. I prefer to study this kind of material. Nicely written information in this post, the quality of content is fine and the conclusion is lovely. Things are very open and intensely clear explanation of issues

    python training in velachery
    python training institute in chennai


    ReplyDelete
  58. UiPath Training in Bangalore by myTectra is one the best UiPath Training. myTectra is the market leader in providing Robotic Process Automation on UiPath
    ui path training in bangalore

    ReplyDelete
  59. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    Good discussion. Thank you.
    Anexas
    Six Sigma Training in Abu Dhabi
    Six Sigma Training in Dammam
    Six Sigma Training in Riyadh

    ReplyDelete
  60. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Devops Training in pune

    ReplyDelete
  61. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

    Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies

    Selenium Training in Bangalore | Best Selenium Training in Bangalore

    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

    ReplyDelete
  62. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
    python training Course in chennai | python training in Bangalore | Python training institute in kalyan nagar

    ReplyDelete
  63. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us. Do check Six Sigma Training in Bangalore | Six Sigma Training in Dubai & Get trained by an expert who will enrich you with the latest trends.

    ReplyDelete
  64. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.

    advanced excel training in bangalore

    ReplyDelete
  65. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in velachery| rpa training in tambaram |rpa training in sholinganallur | rpa training in annanagar| rpa training in kalyannagar

    ReplyDelete
  66. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Java training in Tambaram | Java training in Velachery

    Java training in Omr | Oracle training in Chennai

    ReplyDelete
  67. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    fire and safety course in chennai

    ReplyDelete
  68. Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision. 

    python training Course in chennai
    python training in Bangalore
    Python training institute in bangalore

    ReplyDelete