29

How do I view the contents of a .class file (java byte code)?

How do I open these type of files in Linux? I'm using Centos 5.8.

JoshDM
  • 4,939
  • 7
  • 43
  • 72
karunakar
  • 317
  • 1
  • 3
  • 7

6 Answers6

55

javap -c X will show the disassembly of X.class.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
13

Read bytecode

javap -v com.company.package.MainClass

To understand bytecode You can use this list of mnemonics

Jonathan Drapeau
  • 2,610
  • 2
  • 26
  • 32
Marcin Szymczak
  • 11,199
  • 5
  • 55
  • 63
2

You could decompile it.

To see Java source code check some decompiler. Go search for jad.

If you want to see bytecodes, just use javap which comes with the JDK.

Community
  • 1
  • 1
asgoth
  • 35,552
  • 12
  • 89
  • 98
1

use javap. it's a part of the standard jdk.

fdreger
  • 12,264
  • 1
  • 36
  • 42
0

less filename.class

Not sure how it will help you, unless you can read byte code...

KingCronus
  • 4,509
  • 1
  • 24
  • 49
0

Any binary file editor will do - gHex or xxd are two recommendations.

Note, this won't really help you unless you can understand the bytecode given to you by the .class file...

Makoto
  • 104,088
  • 27
  • 192
  • 230