aspose file tools*
The moose likes Beginning Java and the fly likes how to open a .class file ? can not open with text editors! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to open a .class file ? can not open with text editors!" Watch "how to open a .class file ? can not open with text editors!" New topic
Author

how to open a .class file ? can not open with text editors!

sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
Dear friends,
I have some".class" files but I cannot open them with text editors like notepad and word and not even by netbeans. How can I open it?
the file contains some java classes.

thanks,
Sahar.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18141
    
  39


Class files are binary files. They are not text files, and hence, can't be opened by a text editor.

To view the file, you'll need some sort of editor just for binary files. Or maybe even a decompiler.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
Dear,
Thanks for your complete answer. now I can open the file using Dj Java Decompiler.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9995
    
    7



Well I could "open" mine in notepad. It's a different story that it makes no sense, because, like Henry said, it is a binary file.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10929
    
  12

I would ask you, why do you WANT to open a .class file? Would you open a .exe file?

There are ways to open/look at one, but that's probably not what you REALLY want to do. Is it?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

fred rosenberger wrote:Would you open a .exe file?

Yes. Even if I wouldn't use a resource investigating tool to retrieve bitmaps, icons etc from the exe, I would still open it with rundll32.exe. You might call that "run" the .exe file


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Try the javap tool.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to open a .class file ? can not open with text editors!
 
Similar Threads
What is mean by corrupting of a file?
Logging
Can I write in MS Word File from FileOutputStream Constructor
Problems with newlines in text files
Search tool to search all class files