Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to view a Java class files bytecode [duplicate]

Tags:

java

bytecode

I am working on a bytecode manipulation/generation in Java and I was just wondering if there is an easy way I could check the bytecode. I do not want to decompile the file, I would like to actually look at the compiled bytecode. I do not need to edit it. Any links or programs for doing this would be acceptable answers.

like image 663
Popgalop Avatar asked May 27 '13 13:05

Popgalop


People also ask

Can we see the bytecode?

Also, we can see various details of the bytecode like constant pool, fields, and methods using the Jclasslib plugin dialog: Similarly, we have the Bytecode Visualizer Plugin to view the bytecode of a class file using the Eclipse IDE.

Is bytecode and class file same?

class file is the byte-code. It is the result of compiling java source code (text) into the intermediate format, byte-code. The byte-code is then interpreted by the JVM and compiled into a language understandable by your CPU.

Can you decompile Java bytecode?

Abstract. Java virtual machines execute Java bytecode instructions. Since this bytecode is a higher level representation than traditional ob- ject code, it is possible to decompile it back to Java source.

How do I view the contents of a .class file?

A simple way to see what String literals are used in a ". class" file is to use the javap utility in your JDK installation to dump the file using the "-v" option. Then grep for text that looks like <String "..."> where ... is the String you are looking for.


1 Answers

Since you wanted to be guided to some program that can easily show you the byte code then my suggestion is to use IntelliJ IDEA since it has built-in support for viewing byte code.

Here's an example how to do it (it can also be mapped to some keys of your choice):

enter image description here

enter image description here

It is very easy, and it can surely be done in eclipse or NetBeans as well.

like image 53
maba Avatar answered Oct 23 '22 11:10

maba