This week's book giveaway is in the Agile forum.
We're giving away four copies of Fixing your Scrum and have Ryan Ripley & Todd Miller on-line!
See this thread for details.
Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

source code for pre defined methods

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.Is there any way by which i can see what is happening inside pre defined methods.
i.e. can i see there source code?
if yes please tell me the command for it!

2.Somewhere i learned how to see the content of a pre defined class i.e. by using:

javap java.io.classname

but i dont know what javap means!
can anyone tell me this as well?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In fact the JDK comes with the source code in a zip file for all the classes.

The "javap" command disassembles the class files. here
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say "predefined methods", you mean the standard libraries that come with Java? As K. Tsang has said, it comes with the JDK download. Mine was under:

C:\Program Files\Java\jdk1.8.0_05\src.zip

In Windows, the folder will unzip automatically. Then you can look at the .java file with anything from Notepad to an IDE.

But if you don't have the .java (source) file but only the .class (compiled) file, you can use javap as explained.
 
Marshal
Posts: 73732
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the javap tool displayed the bytecode, not the source code.
If you mean standard J2SE classes, all the well‑known ones are in the src.zip file, as two people have already told you. The zip file is divided into folders and its structure corresponds to the package names of the classes.
 
Ranch Hand
Posts: 116
2
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I thought the javap tool displayed the bytecode, not the source code.


In fact the javap command does display the bytecode, not source code. If you use javap FileName, it will show you the bytecode of the class definitions. If you use javap FileName -verbose it will show you all of the bytecode for the class members as well.
 
Suyash Gulati
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you everyone!
 
Campbell Ritchie
Marshal
Posts: 73732
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
I AM MIGHTY! Especially when I hold this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic