• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read java codes  RSS feed

 
James Jiang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,everyone.I have a problem:when i want to read source codes of some open projects,i don't know where to start since there are too many .java files and i cann't get an entire picture of the project. Does anyone have the same experience,please tell me some advice. thank you a lot!
 
Mintoo kumar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well ,

My suggesation will be ,if your are using any editor then first try to step the project means.In case of Eclipse ,if there is any existing project and you want it to import then.
Step 1. first create the project with the same name which you want to import. e.g if XYZ the name of project which you want to import ,create the new project having name XYZ.

STEP 2. Import or copy the all the structure here at this place.(take care of structure of project also).Now you will able to see your project properly configurable in your editor also add the required jar , lib files.So that you do not encounter more RED cops in editor ,which restrict you to run the code.

Step 3. if you are done with the above step then first find the class from where the inital step begins . i mean to stay there will be definitly a class which will contain either MAIN method or any method which will be acting as GATEWAY to other classes.In eclispe you can view the definition of method using F3 ,select the method and press F3 you will get definition of that method.

Also if you want to know that which all other classes are calling this method ,check out the references.
In my view these are few suggetaion.
Hope above stated lines would be helpful in some manner.
____________________________________________________

Mintoo
SCJP 1.4

________________________________________________________
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if it is a core Java application then you can search how many files have the main function. main method is the execution entry point and ideally in a good package there will be a single main.

If the problem is with other J2EE web enabled projects. Then, just get to know which jsp is the index page and find out with which java file it is interacting.

As, such there are no rules for that you have to follow your wit.
 
James Jiang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your replies. I still have a problem,however,if i get the entry point and then go through all the java codes,then how shall i get a whole picture of the entire project. You know, i jump from one java file to another util the end, which gives me a lot of confuse. Could anyone tell me how to grap the structure from reading codes.
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that requires patience dude. You have to figure out how the classes are organized. Then, you'll require to understand how the program folws and hence how the different classes are linked and what is there utility.

There is no "hot-shot" shortcut to this
 
James Jiang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,i guess so. Every time i want to look through some project,i want to quit and feel so tired.Thank you for your reply.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is something you encountered in your job, then I'd say that the project is insufficiently documented. There should be a document that provides a high-level view of which packages, classes and entry points exist.

Open source projects, of course, are notorious for lacking this kind of documentation.
 
James Jiang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
agree. I can still learn something from them,however. Thank you for all your replies.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!