Search code examples
javanetbeansbytecode

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.


Solution

  • "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.