Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding a large Java program

Tags:

java

I am working on a java project and I have to extend (add more functionality) it. But I don't know how should I learn the existing one before incorporating them. Is there any specific path I should follow? Can I run it in a way so that I can see, statement by statement, the execution of the program?

I am a kind of stuck in understanding it, thanks.

like image 579
Mian Asbat Ahmad Avatar asked Feb 11 '11 22:02

Mian Asbat Ahmad


2 Answers

Here is another approach that is hacky, but I've found useful in the past when unable to attach a debugger. If there is a piece of code that you are looking at, but are having a hard time figuring out who is calling it you can throw a new runtime exception, catch it and print the stack trace.

try {
  throw new RuntimeException("who is calling me");
} catch (RuntimeException e) {
  e.printStackTrace();
}
like image 148
kfox Avatar answered Oct 11 '22 13:10

kfox


You can always fire it up in a debugger/your IDE of choice and step through it all you want, though it's probably best to find someone who is more familiar with the source to provide you an overview, or to look for documentation on where to start.

like image 20
Daniel DiPaolo Avatar answered Oct 11 '22 11:10

Daniel DiPaolo