By using javac.exe
, then I get .class
file. Is .class
file byte code? or Does .class
file include bytecode? After compiling .java
in cmd, where is bytecode?
-
The `.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. – Zabuzard Feb 09 '19 at 10:58
-
2Possible duplicate of [.class vs .java](https://stackoverflow.com/questions/1015340/class-vs-java) – Jaspreet Jolly Feb 09 '19 at 11:11
-
bytecode is series of character understoood by JVM(s) for all platforms. .class is a kind of file, each file has some data written in it. .class file contains bytecode data – nits.kk Feb 09 '19 at 11:15
3 Answers
Yes, a Java class file is a file containing Java bytecode that can be executed on the Java Virtual Machine (JVM).
A Java class file is usually produced by a Java compiler from Java programming language source files (.java files) containing Java classes (alternatively, other JVM languages can also be used to create class files). If a source file has more than one class, each class is compiled into a separate class file.
You can see byte code of .class file using one of the tools, such as javap, jd or jd-gui.

- 2,694
- 2
- 35
- 53
-
why do we need to use `javap` to see the bytecode ? I though we could simply open the `.class` file using a text editor. Apparently it doesn't work, the file rather seems to contain binary information not readable by a standard text editor. – Olivier Boissé Oct 18 '22 at 19:07
-
Exactly because bytecode is binary, javap shows text names of opcodes and operands – jreznot Oct 19 '22 at 20:03
The .class file contains bytecode rather than 'being' the bytecode.
The situation is the same as for (say) .exe files produced from compiler/linker systems that produce native code. The .exe file contains the machine instructions and also contains other information need to prepare those instructions for execution.
Likewise, .class files are structured objects containing the executable bytecode and other information.
The javap
command disassembles one or more .class
files.
javap -c package.MyClass
There are also several libraries and tools that help you to work with Java bytecode, for example ASM and Jasmin.

- 11,718
- 21
- 43
- 52