Java - Is binary code the same as ByteCode?

前端 未结 6 1025
后悔当初
后悔当初 2021-01-31 03:33

In Java, does \"binary code\" means the same as \"Java bytecode?\"

Is this the flow in Java ?

Java File (.java) -> [javac] -> ByteCode File (.

6条回答
  •  旧巷少年郎
    2021-01-31 04:05

    Both C/C++ (to take as an example) and Java programs are compiled into Binary Code. This generic term just means that the new created file does not encode the instructions in a human-readable way. (i.e. You won't be able to open the compiled file in a text program and read it).

    On the other hand, what the Binary 0's and 1's encode (or represent), depends on what the compiler generated. In the case of Java, it generates instructions called Bytecode, which are interpreted by the JVM. In other cases, for other languages, it may generate IA-32 or SPARC instructions.

    In conclusion, the way the terms Binary code and Java bytecode are opposed to each other is misleading. The reason was to make the distinction between the normal binary code which is machine dependant, and the Java bytecode (also a binary code) which is not.

提交回复
热议问题