{"id":25528714,"date":"2022-06-17T17:25:54","date_gmt":"2022-06-17T11:55:54","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25528714"},"modified":"2022-11-23T15:24:20","modified_gmt":"2022-11-23T09:54:20","slug":"top-10-java-debugging-techniques-and-tricks","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/","title":{"rendered":"Top 10 Java Debugging Techniques and Tricks"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e5f70af2496\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e5f70af2496\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#Common_tips\" >Common tips<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#Debugging_Approaches_that_are_Essential_to_Successfully_Executing_JavaScript\" >Debugging Approaches that are Essential to Successfully Executing JavaScript<\/a><\/li><\/ul><\/nav><\/div>\n<header class=\"section__block entry-header\"><\/header>\n<div class=\"entry-content\">\n<p>&nbsp;<\/p>\n<header class=\"entry-header\">\n<p class=\"p-meta\">One of the biggest nightmares for all developers is to debug their code. Debugging code written in Java is a tough task. Debugging is the process of determining and fixing bugs or\u00a0errors\u00a0present in the code, project, or application.<\/p>\n<\/header>\n<div class=\"entry-content content\">\n<p>Debugging your application helps you improve the quality of the code. It is a must-have skill for every Java programmer. Debugging also helps you to understand the flow of program code.<\/p>\n<p><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25520910 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png\" alt=\"Python and Machine Learning Square\" width=\"345\" height=\"345\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png 345w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-300x300.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-150x150.png 150w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-24x24.png 24w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-48x48.png 48w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-96x96.png 96w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-75x75.png 75w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/p>\n<p>This article provides some tips to debug Java program code. We will highlight some common\u00a0run-time issues\u00a0and will use the GUI-based\u00a0<em>Eclipse<\/em>\u00a0IDE. There are other\u00a0IDEs\u00a0available like IntelliJ, and both IDEs have great support for Java debugging. You can set various line breakpoints, conditional breakpoints, and exception breakpoints. Eclipse also provides support for remote debugging.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<p>So let\u2019s explore these Java debugging tips.<\/p>\n<ol>\n<li>Use conditional breakpoint<\/li>\n<li>Use exception breakpoints<\/li>\n<li>Watchpoint<\/li>\n<li>Step filtering<\/li>\n<li>Evaluate (inspect and watch)<\/li>\n<li>Drop to frame<\/li>\n<li>Environment variables<\/li>\n<li>Show logical structure<\/li>\n<li>Modify values of variable<\/li>\n<li>Stop in Main<\/li>\n<\/ol>\n<h3 id=\"top-10-java-debugging-tips-1\"><strong>1. Use conditional breakpoint<\/strong><\/h3>\n<p>A conditional breakpoint is a better approach if you are working with the\u00a0Java programming language\u00a0and debugging your code in\u00a0<em>Eclipse IDE<\/em>. Eclipse allows you to use conditional breakpoints in order to remove bugs in the program code. It\u2019s a breakpoint with a specified condition where the thread will stop at the targeted line when it\u2019s true, unlike a line breakpoint.<\/p>\n<p>This code snippet will be\u00a0used as an example for setting up a conditional breakpoint.<\/p>\n<pre class=\"prettyprint prettyprinted\"><span class=\"kwd\">public<\/span> <span class=\"kwd\">void<\/span><span class=\"pln\"> demo1<\/span><span class=\"pun\">()<\/span> <span class=\"pun\">{<\/span>\r\n    <span class=\"typ\">AList<\/span><span class=\"pun\">&lt;<\/span><span class=\"typ\">String<\/span><span class=\"pun\">&gt;<\/span><span class=\"pln\"> li <\/span><span class=\"pun\">=<\/span><span class=\"pln\"> pList<\/span><span class=\"pun\">();<\/span>\r\n    <span class=\"kwd\">for<\/span> <span class=\"pun\">(<\/span><span class=\"kwd\">int<\/span><span class=\"pln\"> i<\/span><span class=\"pun\">=<\/span><span class=\"lit\">0<\/span><span class=\"pun\">;<\/span><span class=\"pln\"> i<\/span><span class=\"pun\">&lt;<\/span><span class=\"pln\">li<\/span><span class=\"pun\">.<\/span><span class=\"pln\">size<\/span><span class=\"pun\">();<\/span><span class=\"pln\"> i<\/span><span class=\"pun\">++)<\/span> <span class=\"pun\">{<\/span>\r\n        <span class=\"typ\">System<\/span><span class=\"pun\">.<\/span><span class=\"kwd\">out<\/span><span class=\"pun\">.<\/span><span class=\"pln\">println<\/span><span class=\"pun\">(<\/span><span class=\"pln\">li<\/span><span class=\"pun\">.<\/span><span class=\"kwd\">get<\/span><span class=\"pun\">(<\/span><span class=\"pln\">i<\/span><span class=\"pun\">));<\/span>\r\n    <span class=\"pun\">}<\/span>\r\n<span class=\"pun\">}<\/span><\/pre>\n<p>You are required to set up a breakpoint on a line inside the loop only when the value of the element\u00a0<em>li<\/em>\u00a0is equal to a specific value. To set up a conditional breakpoint, use the following steps:<\/p>\n<ul>\n<li>Double-click on the line where you want to put a breakpoint.<\/li>\n<li>Right-click the breakpoint and select\u00a0Breakpoint Properties\u00a0as shown in Figure 1.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22537 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/breakpoint-properties.png\" alt=\"\" width=\"266\" height=\"291\" \/><\/p>\n<ul>\n<li>Tick the\u00a0conditional\u00a0checkbox under Breakpoint properties as shown in Figure 2.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22535 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/java-debugging-tips-line-breakpoint.png\" alt=\"\" width=\"437\" height=\"360\" \/><\/p>\n<ul>\n<li>Put the condition as per your requirement in the text area and click on\u00a0OK.<\/li>\n<\/ul>\n[Note:\u00a0One thing you need to remember while specifying the condition is that it should return a\u00a0Boolean\u00a0value.]\n<p>So when the specified condition is true, the program will stop but not otherwise. The program is now executing in the\u00a0debug mode.<\/p>\n<h3 id=\"top-10-java-debugging-tips-2\"><strong>2. Use exception breakpoints<\/strong><\/h3>\n<p>While debugging Java program code in Eclipse, you are often encountered with a\u00a0NullPointerException\u00a0error. Sometimes you are not aware of the origin of the error, which can be frustrating.<\/p>\n<p>Developers of Eclipse have provided with a solution for such issues in the form of\u00a0exception breakpoints. This feature is also available in the NetBeans IDE.<\/p>\n<p>Now you can simply use an exception breakpoint for\u00a0NullPointerException\u00a0and ArrayIndexOutofBoundException.<\/p>\n<p>The exception breakpoint can be easily set up from the breakpoint window.<\/p>\n<p>Figure 3 shows the breakpoint window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22534 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/java-debugging-tips-breakpoint-window.png\" alt=\"\" width=\"395\" height=\"312\" \/><\/p>\n<p>You can see that there is a button labeled\u00a0<strong>J!<\/strong>\u00a0in the breakpoint window. This button is used to put an exception breakpoint in the program code. The execution of the program will stop whenever the specified exception occurs.<\/p>\n<h3 id=\"top-10-java-debugging-tips-3\"><strong>3. Watchpoint<\/strong><\/h3>\n<p>The\u00a0watchpoint\u00a0is a breakpoint set up on a field or variable. It is the best feature of the Eclipse IDE. Each time the targeted field or variable is accessed or changed, the execution of the program will get stop and then you can debug.<\/p>\n<p>The following steps will help you to set up a watchpoint:<\/p>\n<ul>\n<li>Double-click on the left-margin (just next to the field declaration). A sign will appear as shown in Figure 4.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22538 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/watchpoint.png\" alt=\"\" width=\"708\" height=\"112\" \/><\/p>\n<ul>\n<li>Configure the properties of the watchpoint as shown in Figure 5. The program execution will halt each time the attribute is read or changed or both.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22540 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/configure-watchpoint.png\" alt=\"\" width=\"441\" height=\"189\" \/><\/p>\n<ul>\n<li>Once you have successfully set up the Watchpoint, then it will get listed in the\u00a0<strong>Breakpoints view<\/strong>.<\/li>\n<\/ul>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22539 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/watchpoint-properties.png\" alt=\"\" width=\"383\" height=\"358\" \/><\/h3>\n<h3 id=\"top-10-java-debugging-tips-4\"><strong>4. Step filtering<\/strong><\/h3>\n<p>While performing\u00a0Step Into\u00a0during debugging process, sometimes it happens that the control of the program goes from one class to other class and eventually, you are moved to the\u00a0external libraries\u00a0or\u00a0JDK classes\u00a0like\u00a0System\u00a0or\u00a0String.<\/p>\n<p>This feature will assist you in skipping some particular packages during the debugging process.<\/p>\n<p>You can easily set up step filtering with the following steps:<\/p>\n<ul>\n<li>Go to\u00a0<strong>Windows<\/strong>.<\/li>\n<li>Click on\u00a0<strong>Preferences<\/strong>.<\/li>\n<li>Click on\u00a0<strong>Java<\/strong>.<\/li>\n<li>Select\u00a0<strong>Debug<\/strong>.<\/li>\n<li>Choose\u00a0<strong>Step Filtering<\/strong>.<\/li>\n<\/ul>\n<p>A window will appear on your screen.<\/p>\n<p>Later, if you want to enable or disable the step filtering option, you can do it from the Debug window.<\/p>\n<h3 id=\"top-10-java-debugging-tips-5\"><strong>5. Evaluate (inspect and watch)<\/strong><\/h3>\n<p>This is another good feature of the Eclipse IDE. This feature will enable you to check the value of expressions while debugging Java programs. All you need to do is right-click the statement and click on inspect. It will show you the value of the selected expression during the debugging process. The value will appear in front of you over the watch window.<\/p>\n<p>Figure below explains the image of the watch window in which the value of an expression is displayed.<\/p>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22541 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/watch-window.png\" alt=\"\" width=\"416\" height=\"379\" \/><\/h3>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<h3 id=\"top-10-java-debugging-tips-6\"><strong>6. Drop to frame<\/strong><\/h3>\n<p>Eclipse enables users to choose any frame (level) in the call stack during the debugging process and set the JVM to start again from the selected level. In simple words, it allows you to re-run a part of your program.<\/p>\n[<strong>Note:<\/strong>\u00a0The changes made to the variable will not be reset.]\n<p>The following steps will help you use this feature:<\/p>\n<ul>\n<li>Select the stack from where you want to start as shown in Figure below.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22542 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/select-stack.png\" alt=\"\" width=\"502\" height=\"179\" \/><\/p>\n<ul>\n<li>Click on the\u00a0Drop to Frame button in the toolbar of the debug window. A new window will appear on the screen as displayed in Figure.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22543 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/drop-frame.png\" alt=\"\" width=\"499\" height=\"160\" \/><\/p>\n<h3 id=\"top-10-java-debugging-tips-7\"><strong>7. Environment variables<\/strong><\/h3>\n<p>As you know, it is important to set up environment variables prior to coding in Java. We all are aware of how to set up environment variables. We need to go to the system properties in order to add an environment variable. Eclipse allows you to do it from the IDE itself.<\/p>\n<p>There is no need to follow the traditional path to set the environment variables. You can easily do the same through\u00a0Edit Configuration\u00a0dialog box.<\/p>\n<p>Figure below shows the image of the Edit Configuration dialog box.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22544 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/edit-configuration.png\" alt=\"\" width=\"316\" height=\"427\" \/><\/p>\n<h3 id=\"top-10-java-debugging-tips-8\"><strong>8. Show logical structure<\/strong><\/h3>\n<p>It is not easy to check the values of a map or a list with the default settings of the Eclipse. You need to edit them or choose another way.<\/p>\n<p>The logical structure option is very useful, especially when trying to determine the contents of Java collection classes such as\u00a0<strong>HashMap<\/strong>\u00a0or\u00a0<strong>ArrayList<\/strong>. Instead of displaying the detailed information, the logical structure will present only the necessary content such as the key and value of a HashMap.<\/p>\n<p>You can easily enable the Show Logical Structure option with the help of a button. This option is very handy, especially if you don\u2019t have meaningful\u00a0<strong>toString()<\/strong>\u00a0methods for the objects in your structure.<\/p>\n<p>Below figure displays the position of show logical structure\u00a0button.<\/p>\n<div id=\"attachment_22396\" class=\"wp-caption alignnone\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-22396 size-full no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/image-result-for-show-logical-structure-eclipse.gif\" alt=\"Image result for show logical structure eclipse\" width=\"301\" height=\"251\" aria-describedby=\"caption-attachment-22396\" \/><\/p>\n<\/div>\n<h3 id=\"top-10-java-debugging-tips-9\"><strong>9. Modify the value of a variable<\/strong><\/h3>\n<p>Eclipse allows you to change the values of variables during the debugging process. There is no need to restart your debugging session with minor changes in the code. You can continue to debug the program code. It will save time.<\/p>\n<p>Figure below shows how to change the value of a variable.<\/p>\n<div id=\"attachment_22397\" class=\"wp-caption alignnone\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-22397 size-full no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/change-value.png\" alt=\"Change Value\" width=\"658\" height=\"296\" aria-describedby=\"caption-attachment-22397\" \/><\/p>\n<\/div>\n<h3 id=\"top-10-java-debugging-tips-10\"><strong>10. Stop in Main<\/strong><\/h3>\n<p>This feature is present in the\u00a0Edit configuration\u00a0window of the\u00a0Debug settings. When a program is debugged with this feature enabled, the execution will stop at the first line of the main function.<\/p>\n<p>In order to enable this feature, open the Edit configuration window and mark the checkbox which states\u00a0stop in main.<\/p>\n<p>Below figure illustrates how to enable the stop in the main feature.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22545 no-lazyload\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2018\/09\/enable-stop-main-feature.png\" alt=\"\" width=\"416\" height=\"312\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Common_tips\"><\/span><strong>Common tips<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Apart from the above-mentioned tips, I\u2019ve listed some common tips below.<\/p>\n<ul>\n<li>In case you want to copy the entire stack of a thread, you can do so with the help of the\u00a0Copy Stack\u00a0option. Right-click on the thread in the\u00a0Debug Window and select \u201cCopy Stack\u201d.<\/li>\n<li>You can also\u00a0suspend and resume threads\u00a0while debugging Java program code through the debug window.\u00a0Right-click on any thread and select suspend or resume, as desired. This is a very helpful feature while debugging multi-threaded programs.<\/li>\n<li>With the help of the\u00a0Step Into\u00a0(F5) feature, you can move to the next step and check whether the current line has a method call or not. If yes, then the control will go to the first line of the called method.<\/li>\n<li>The\u00a0Step over\u00a0(F6) feature will help you to move control to the next line. If there is any method call present at the current line, it will be executed first, and control will only move to the next line.<\/li>\n<li>Under the\u00a0step return\u00a0(F7) option, control will go to that line where the current method is called or invoked.<\/li>\n<\/ul>\n<header class=\"section__block entry-header\">\n<h2 class=\"entry-header__title\"><span class=\"ez-toc-section\" id=\"Debugging_Approaches_that_are_Essential_to_Successfully_Executing_JavaScript\"><\/span><strong>Debugging Approaches that are Essential to Successfully Executing JavaScript<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<\/header>\n<div class=\"entry-content\">\n<p>Debugging in JavaScript may seem like a difficult task. With all the build processes and code manipulation, it can be hard to track down certain bugs. In this blog, we will learn about some tried and true debugging tips and techniques that can help track down bugs more quickly. Many of the approaches will be centered around Chrome, although Firefox and Safari have very similar techniques and tools.<\/p>\n<h4><strong>Enabling Source Maps in WebPack to Locate Bug Files<\/strong><\/h4>\n<p>If there is a build process going on that packs JavaScript assets, such as WebPack, enabling source maps is a necessity. WebPack (a technology we use in multiple CQL projects) makes it pretty simple to generate source maps \u2013 you just add a <code>devtools: 'eval-source-map'<\/code>\u00a0property. Now, stack traces will show you the source file with the bug. Another bundler that has generated a buzz around the office is Parcel, a zero-configuration bundler that has source mapping enabled by default.<\/p>\n<h4><strong>Preventing JavaScript Execution with\u00a0<code>Debugger<\/code>\u00a0Keyword<\/strong><\/h4>\n<p>There are ways of stopping JS execution so we can gain insight into exactly what\u2019s happening at execution time. The first method is the JS\u00a0<code>debugger<\/code>\u00a0keyword. This is a great way to stop execution if we happen to know where the bug is occurring already. Just open the source file, inspect the code (maybe it\u2019s an easy bug when we look at it with that skeptical eye), and type\u00a0<code>debugger;<\/code>\u00a0some lines before the bug.<\/p>\n<p>Next, open the inspector in Chrome (Command+Option+I on Mac, Control+Shift+I or F12 on Windows), reload the page, and rerun the problem code again. When JS execution gets that new\u00a0<code>debugger<\/code>\u00a0line, the focus will shift to the Sources tab. The main window shows the file, and the right sidebar is where the code navigation\/variables\/call stack\/fun stuff can be found.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3053\" src=\"https:\/\/www.cqlcorp.com\/wp-content\/uploads\/2019\/11\/Debugging-Source-Image.png\" srcset=\"https:\/\/www.cqlcorp.com\/wp-content\/uploads\/2019\/11\/Debugging-Source-Image.png 360w, https:\/\/www.cqlcorp.com\/wp-content\/uploads\/2019\/11\/Debugging-Source-Image-280x350.png 280w\" alt=\"\" width=\"284\" height=\"355\" data-src=\"https:\/\/www.cqlcorp.com\/wp-content\/uploads\/2019\/11\/Debugging-Source-Image.png\" data-srcset=\"https:\/\/www.cqlcorp.com\/wp-content\/uploads\/2019\/11\/Debugging-Source-Image.png 360w, https:\/\/www.cqlcorp.com\/wp-content\/uploads\/2019\/11\/Debugging-Source-Image-280x350.png 280w\" data-sizes=\"(min-width: 960px) 75vw, 100vw\" \/><figcaption>Above: A visual of the right sidebar in Chrome Inspector\u2019s Sources tab<\/figcaption><\/figure>\n<\/div>\n<p>Note that a Console can also be opened while the Sources tab focused, just press\u00a0<code>Esc<\/code>! The console can be used to test code against local or global variables. For example, if there\u2019s a variable called`<code>title<\/code>\u00a0holding a string, by typing\u00a0<code>title.<\/code>, Chrome will start suggesting methods that can be used on a string like\u00a0<code>length<\/code>. Thanks to Chrome\u2019s Eager Evaluation, the code doesn\u2019t need to be run for many methods, it will simply show the output before running. You can try this now in a console \u2013 type any string (like \u201cdebugging is fun!\u201d) and start using some string methods on it.<\/p>\n<p>Back to the code navigation in the right sidebar. The main navigation buttons are the Resume script execution, Step over next function call, Step into next function call, Step out of current function, and Step. Resume script execution does just that. If we are done debugging this particular area of code, press this and the code will continue until it is complete, or it hits another breakpoint. Step is the most basic navigation option. This simply moves to the next line in the code. If the line happens to call another function, this will step into that function. Step over the next function call skips whatever the next function is. If we are stopped on a line that calls another function, but we don\u2019t want to step into that other function, this button will ignore that function.<\/p>\n<h4><strong>What to Do When\u00a0<code>Debugger<\/code>\u00a0Keyword Doesn\u2019t Hit<\/strong><\/h4>\n<p>Sometimes, the bug may be a little harder to find than first expected. Perhaps the\u00a0<code>debugger<\/code>\u00a0added to the source file didn\u2019t hit. This can indicate that there is a bug occurring\u00a0<em>before<\/em> the spot originally suspected. In this scenario, there\u2019s another handy button in the Chrome Inspector\u2019s Sources tab, which is the \u201cPause on exceptions\u201d button.<\/p>\n<p>When the code hits an exception, the execution will stop at the exact line the execution was thrown. The Call Stack area is the answer this time. It shows all of the events that led up to the current exception, with the most recent call at the top. Just look for the call that comes from your source file. This is where the bug probably lives. The code written in the source file may be sending the wrong type to some method, or maybe missing some property on some argument somewhere. The point is, now we have another place to investigate this bug, so a\u00a0<code>debugger<\/code>\u00a0keyword can be used, or a breakpoint can be added right in the sources tab. To add a breakpoint right in the sources tab, open the problem file by using Command+P or Command+O (Contrl+P\/Control+O on Windows) and typing in the file name, then clicking on a line number. Execution will stop the next time it hits this line.<\/p>\n<h4><strong>Deactivating Breaking Points to Resume Execution<\/strong><\/h4>\n<p>By the time a bug is fixed, there may be\u00a0<code>debugger<\/code>\u00a0statements and breakpoints lying around everywhere that we may not need to stop at anymore. In this case, use the \u201cDeactivate breakpoints\u201d button. When execution is resumed again, it will no longer stop at breakpoints.<\/p>\n<p><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25520910 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png\" alt=\"Python and Machine Learning Square\" width=\"345\" height=\"345\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png 345w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-300x300.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-150x150.png 150w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-24x24.png 24w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-48x48.png 48w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-96x96.png 96w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-75x75.png 75w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Grab the opportunity to learn Python with Entri! Click Here<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; One of the biggest nightmares for all developers is to debug their code. Debugging code written in Java is a tough task. Debugging is the process of determining and fixing bugs or\u00a0errors\u00a0present in the code, project, or application. Debugging your application helps you improve the quality of the code. It is a must-have skill [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":25529009,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1882],"tags":[],"class_list":["post-25528714","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-java-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Top 10 Java Debugging Techniques and Tricks - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 10 Java Debugging Techniques and Tricks - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"&nbsp; One of the biggest nightmares for all developers is to debug their code. Debugging code written in Java is a tough task. Debugging is the process of determining and fixing bugs or\u00a0errors\u00a0present in the code, project, or application. Debugging your application helps you improve the quality of the code. It is a must-have skill [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-17T11:55:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-23T09:54:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Feeba Mahin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Feeba Mahin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\"},\"author\":{\"name\":\"Feeba Mahin\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\"},\"headline\":\"Top 10 Java Debugging Techniques and Tricks\",\"datePublished\":\"2022-06-17T11:55:54+00:00\",\"dateModified\":\"2022-11-23T09:54:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\"},\"wordCount\":2325,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png\",\"articleSection\":[\"Articles\",\"Java Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\",\"url\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\",\"name\":\"Top 10 Java Debugging Techniques and Tricks - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png\",\"datePublished\":\"2022-06-17T11:55:54+00:00\",\"dateModified\":\"2022-11-23T09:54:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png\",\"width\":820,\"height\":615,\"caption\":\"Top 10 Java Debugging Techniques and Tricks\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Top 10 Java Debugging Techniques and Tricks\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\",\"name\":\"Feeba Mahin\",\"url\":\"https:\/\/entri.app\/blog\/author\/feeba123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Top 10 Java Debugging Techniques and Tricks - Entri Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/","og_locale":"en_US","og_type":"article","og_title":"Top 10 Java Debugging Techniques and Tricks - Entri Blog","og_description":"&nbsp; One of the biggest nightmares for all developers is to debug their code. Debugging code written in Java is a tough task. Debugging is the process of determining and fixing bugs or\u00a0errors\u00a0present in the code, project, or application. Debugging your application helps you improve the quality of the code. It is a must-have skill [&hellip;]","og_url":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-06-17T11:55:54+00:00","article_modified_time":"2022-11-23T09:54:20+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png","type":"image\/png"}],"author":"Feeba Mahin","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Feeba Mahin","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/"},"author":{"name":"Feeba Mahin","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36"},"headline":"Top 10 Java Debugging Techniques and Tricks","datePublished":"2022-06-17T11:55:54+00:00","dateModified":"2022-11-23T09:54:20+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/"},"wordCount":2325,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png","articleSection":["Articles","Java Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/","url":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/","name":"Top 10 Java Debugging Techniques and Tricks - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png","datePublished":"2022-06-17T11:55:54+00:00","dateModified":"2022-11-23T09:54:20+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/06\/Top-10-Java-Debugging-Techniques-and-Tricks.png","width":820,"height":615,"caption":"Top 10 Java Debugging Techniques and Tricks"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/top-10-java-debugging-techniques-and-tricks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Java Programming","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/"},{"@type":"ListItem","position":4,"name":"Top 10 Java Debugging Techniques and Tricks"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36","name":"Feeba Mahin","url":"https:\/\/entri.app\/blog\/author\/feeba123\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25528714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25528714"}],"version-history":[{"count":7,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25528714\/revisions"}],"predecessor-version":[{"id":25548030,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25528714\/revisions\/25548030"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25529009"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25528714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25528714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25528714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}