• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is javap and how is it used?

 
k Oyedeji
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can anyone explain what this tool does, i tried to use it using a class in the local directory after reading the availble options but everything i tried returns a class not found error message

Thanks
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you compile the class with javac, you can use javap -c to "decompile" the class. It will list the methods, etc.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi "k",
I am assuming that "javap" is on your path (to confirm, just type the command:
javap -help
and you should get a "help" message)
Now I'm assuming that you have a class called "MyClass" that you want to use "javap" on. So, according to your description, there should be a file named "MyClass.class" in the current directory. If all the above is correct, then you should type this command (to achieve your desired result):
javap -classpath . MyClass
[Note: The above was tested on a Windows 98 computer with JDK 1.4.1]
Hope this helps you.
Good Luck,
Avi.
 
Divya Venkatesh
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well! Can someone please tell me what javap is all about.
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javap is a disassembler. If you use the -c option, it will print out a human readable version of the bytecode. There are also decompilers (such as JODE) which go one step further and create normal java source code from bytecode, but javap does not. To understand it, you'll have to do some reading of the Java VM Spec.
 
Dirk Schreckmann
Sheriff
Posts: 7023
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic