• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 7113
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: 74712
335
  • 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: 74712
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic