How to use debug perspective in eclipse.[debugging java/j2ee applications]

前端 未结 2 1295
夕颜
夕颜 2021-01-25 12:10

Is there any easy to follow tutorial for debugging Java / J2EE applications in eclipse? A step by step guide on how to check for unchecked and checked exceptions? I have been tr

2条回答
  •  盖世英雄少女心
    2021-01-25 13:15

    The debugger in Eclipse will automatically suspend execution (and let you inspect variables/step/resume etc) if an uncaught exception is thrown.

    Enter for instance the following program...

    public class Test {
    
        public void methodA() {
            methodB("hello");
            methodB(null);
        }
    
        public void methodB(String s) {
            System.out.println(s.substring(2));
        }
    
        public static void main(String[] args) {
            new Test().methodA();
        }
    }
    

    ... and click the little "bug"-icon or choose Run -> Debug As -> Java Application

    enter image description here


    A few useful tutorials

    • Debugging a Java Program with Eclipse
    • Java Debugging with Eclipse - Tutorial

提交回复
热议问题