Java files can be compiled. The output is a machine understandable file that has a .class extension which can be executed by the JVM
This is because Java runs it's code through a Virtual Machine which compiles it and runs it. C will compile native on your machine and the code will be run directly, without the use of a virtual machine.
when we compile a file in java, it creates a byte code which later on gets interpreted to machine understandable code. byte code is not machine language. where system understands only machine language. hence the interpretation of byte code is required.
native code is machine code each machine has its won set of istruction one machine's native code won't run on another While bytecode is what java produces and it can run on any machine. when we run bytecode it first get to compile to machine code and then get to run.
The main reason for this is that C code compiles down to native machine code. Java bytecode needs to be run in the JVM, which may or may not compile it down to native code.
The source code is just the set of statements written in (any included) java language by a programer (in this case our source code is a text file with .java extension). And in other hand a bytecode is the resulting code of compile a .java file, It is not machine code, but it can be interpreted and executed by the jvm.
Yes, Java programming language has a Garbage collector for unused memory. and the best part about it is that it does it automatically. The Garbage Collector is built into the Java Virtual Machine, and will do automatic garbage collection for you. If you chose to compile your Java code down to native code (via a Java->native code compiler), then NO garbage collection is done for you.
It can easily be explained by the fact that Java does not compile to object code. Java compiles to byte code that is suitable for interpretation by the Java virtual machine. C++ compiles to native machine code and therefore does not require interpretation of any kind. As a result, C++ programs run somewhat quicker than equivalent Java programs. However, because Java is interpreted, it is highly portable. Any machine with a Java virtual machine implementation (which is pretty much every device today) can run Java programs built from a single compilation. C++ requires that the code be written specifically for each platform and that the source be compiled separately upon each supported platform.
The Java virtual machine is not a compiler, it is an interpreter which primarily performs runtime-translation of Java byte code (the native language of the Java virtual machine) to machine-code (the native language of the physical machine). The Java compiler, on the other hand, is a separate program used to perform compile-time conversion of high-level Java source code to the lower level byte code. Java byte code is highly portable; once compiled, any architecture or platform that implements a JVM can execute the byte code without modification.
Compiling is the act of translating human-readable source code to machine-readable byte code.In Java, the compiler program is javac
The JVM (Java Virtual Machine) is a part of the JRE (Java Runtime Environment).The JRE is comprised of the JVM and the Class Library.The JVM takes the java language and compiles it into Bytecode which can then be interpreted as machine code by the platform(OS). The JVM will compile byte code specific to the OS it is being deployed upon. The JVM allows the Java language to be platform independent.
Java byte code is the code that is output by the Java compiler. Byte code is not machine code, it must be interpreted to create the machine code. This is handled by the Java virtual machine. Pretty much every platform produced today has a Java virtual machine implementation, so the same byte code can be executed upon any machine. Byte code can be regarded as being the native language of the virtual machine, as opposed to machine code which is the native language of the physical machine.
The main advantage is that C++ programs compile to native machine code and therefore execute many times faster than equivalent Java programs, which compile to byte code suitable for interpretation by the Java virtual machine. C++ is also more efficient since it requires no interpretation (and therefore no interpreter), and can use memory just as efficiently as assembler. The main disadvantage is the code must be compiled separately for each platform. With Java, programs need only be compiled once for any platform.