Solved

Debugging Java code in Eclipse

Posted on 2003-11-14
3
400 Views
Last Modified: 2013-12-14
I am a recent convert form VB/ VB.net to Java.  So far the onlyt thing I miss about MS are the debugging tools.  The MS IDE provided a "step through" feature, allowing me to execute code 1 line at a time (stepping through or around modules as necessary) does anyone know if Eclipse offers this feature- if so how is it used.  Thank you.

0
Comment
Question by:mandalorian4
  • 2
3 Comments
 
LVL 2

Expert Comment

by:SuperKarateMonkey
ID: 9750629
Yes, Eclipse does.  It lets you set breakpoints, step through code line-by-line, view variable values at each given time, pretty much everything java does.  You just need to right-click on a section of your code and choose "Set Breakpoint."

0
 
LVL 2

Accepted Solution

by:
SuperKarateMonkey earned 125 total points
ID: 9750808
Eclipse, like almost every java IDE out there, takes advantage of an application bundled with the JDK, called the Java Debugger, and it's located at:

%JAVA_HOME%/bin/jdb.exe

It acts almost identically to java.exe, only it calls TWO JVM's, instead of one, using the first for viewing the process, and the second as the actual virtual machine.  You can, in fact, use it yourself if you want, without the aid of an IDE, but it's a collosal pain to try to step through your code using the command line.

To run it in Eclipse, you do two things:

1.  Create a breakpoint:  Right-click to the left of the text area at the line you want to add a breakopint, and choose "Add Breakpoint." You could also just press Ctrl-Shift-B, or you could choose the line where you want to add the breakpoint and go through the menu:

Run -->Add/Remove Breakpoint

2.  Run the debugger: You go the the little Icon on the top near the Save, Save As, and Print icons, the one that looks an insect like a small insect, and choose Debug As... --> Java Application.  The same thing can be done from the Run.. menu item, as well.  When it starts debugging it will send you into the debugger view and you'll be able to step over, (line by line,) or into, (into each method,) your code.  One of the sub-windows should have a tab on the bottom that reads: variables.  Click that and you can see the current state of all variables in your application.n  The icons at the top of the sub-window marked "Debug" should give you the option, at each breakpoint to continue, stop, step over, step into, etc...

Hope this is enough.  Pity we all can't attach images.  I've got it running right now...
0
 
LVL 1

Expert Comment

by:allelopath
ID: 9750931
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 81
@SBGen Method 3 38
starter POM and spring-boot-starter,  spring-boot-web 2 43
Java Jpanels and Jframe 8 28
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now