Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read .class file? [duplicate]

I need to read the contents of .class file of java in my java program or is there any method available to read the same.Actually I want to retrieve the local variable table ,line number table,etc from .class file of java but I'm not getting any method to read the same?

like image 726
Neha Avatar asked Apr 01 '11 19:04

Neha


People also ask

How do you fix a duplicate class error in Java?

In such a case, the module is copied in the javasource folder in the app directory with a new name and the old folder is kept, resulting in two identical folders with different names. Simply delete the copied folder with the modulename that is not used and you should be fine.

Is .class file readable?

out. println . Because developers cannot read . class files, they should also provide an API (Application Programming Interface) along with their code.

What does duplicate class mean?

The "duplicate class" error can also occur when the class is named the same with the same package naming hierarchy, even if one of the classes exists in a directory structure with directory names different than the package names.


2 Answers

I want to retrieve the local variable table ,line number table,etc

To read those you will need ASM, BCEL or a similar bytecode library. Java's reflection API does not tell them to you.

like image 143
Esko Luontola Avatar answered Oct 07 '22 01:10

Esko Luontola


You need a Java decompiler or something like that

like image 44
RoflcoptrException Avatar answered Oct 07 '22 00:10

RoflcoptrException