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.
3 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.
1 Comment
javac, when he’s already using Netbeans which produces the class files and even jar files ready to hand out to someone else. Since the OP obviously is a beginner, we shouldn’t make his life harder than necessary. Mentioning the word “compiler” would help here…Your teacher is requesting that you send in the source code and also the compiled source code (thats the "bytecode"). This e.g. allows him to test your application with some input parameters.
You can find more about byte code here.
Comments
step by step procedure
- At desktop create folder "demoProjectFolder"
- Create project say "test" in your IDE.
- While creating project select project location as "demoProjectFolder".
- Now in IDE Inside src create HelloWorld.java with say just simple printing "Hello World".
- now navigate to src location in my case its "cd /Users/viveksingh/Desktop/demoProjectFolder/src". Now run javac HelloWorld.java
- Inside demoProjectFolder at src folder location inside HelloWorld.class will get created