Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Java source code to Byte Code?

My IDE is Netbeans. My professor asks me to submit the homework in both source code (.java files) and byte code. But I don't know how to convert my source code to byte code. I searched it on google but didn't find the answer. Please help. Thank you.

like image 624
Louis Tran Avatar asked Nov 05 '25 14:11

Louis Tran


1 Answers

"Byte code" is what .class-files contain. The javac program takes source files as input and produces bytecode files.

If you have a source file homework/Main.java you would produce the corresponding bytecode file by running javac homework/Main.java. This would then produce a file homework/Main.class.

For more information, see https://docs.oracle.com/javase/7/docs/technotes/tools/#basic.

like image 139
Viktor Dahl Avatar answered Nov 08 '25 10:11

Viktor Dahl