File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Read Byte Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Read Byte Code" Watch "Read Byte Code" New topic
Author

Read Byte Code

Gautam Sathe
Greenhorn

Joined: May 24, 2001
Posts: 18
Can we read byte code (i.e. the contents of .class file)? If so what is the command?
------------------
Ender Everett
Greenhorn

Joined: Mar 31, 2001
Posts: 19
If you're in Windows, you could go to the MS-DOS prompt and open up any *.class file in the text editor. Enter the editor by typing
c:\whatever\>edit
Most people don't use the DOS editor these days... I'm an old fashioned Command-Line Commando...
-Ender
PS: I hope that's what you meant. You can also enter
c:\>more <*filename*.class
and it will output the contents to the screen. The only problem with this is that the machine codes affect the output of "more <*.*" very heavily, so you won't see the true contents...and sometimes you get old-school DOS beeping noises, which are annoying.
[This message has been edited by Ender Everett (edited June 01, 2001).]


Don't sweat the petty stuff, just pet the sweaty stuff.
manish paliwal
Greenhorn

Joined: May 18, 2001
Posts: 16
dear,
u should read first Input/Output Stream ( java.io.*)
ok byee
------------------
manish paliwal(or just mann )


manish paliwal(or just mann )
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
I think what he is asking for is a decompiler. If you do a search on decompiler (in google or yahoo or wherever) you will find lot's of free ones to play with.
However if the code has been obfuscated then it becomes exceedingly harder.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Ender Everett
Greenhorn

Joined: Mar 31, 2001
Posts: 19
AH! yeah, I thought he was wanting to look at the actual byte code itself.
If you want a good decompiler, check out DJ Java Decompiler ver 2.???. It's on Download.com last time I checked, and it does a pretty good job. Your OS must be Windows, I think, to use it.
Which brings up an odd question: Are there any Java decompilers written in Java?
Gautam Sathe
Greenhorn

Joined: May 24, 2001
Posts: 18
One of my friend told me that there is some java*.exe in command to read the byte code? I am not looking for decompiler like DJ Decompiler.
------------------
Ender Everett
Greenhorn

Joined: Mar 31, 2001
Posts: 19
OK, You've got me confused now... what exactly do you mean when you say "read byte code"?
If you mean open it up and take a look at what actual characters are in your byte code file, the way I listed in my first post is one among many methods. (there's absolutely nothing to see in bytecode, however... it is even less useful than machine language, as it is interpreted, not the machine-form of assemlby)
If you mean decompile (which you just said you didn't), then the decompilers are the way...
You've got me really confused now... what do you mean? And what is it that you are trying to do in the end? Perhaps there is a better way of phrasing the question.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
There is a javap.exe program that will read the byte code and give you a summary of the fields and methods signatures, but it does not show the code that is going on IN those methods. Is that what you are looking for? I believe that the class has to be available outside a jar file for it to work.
>javap MyClass

[This message has been edited by Cindy Glass (edited June 02, 2001).]
Gautam Sathe
Greenhorn

Joined: May 24, 2001
Posts: 18
Thanks Cindy I was looking for this command.
Gautam.

------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read Byte Code