+ 1
I still don't understand the JVM concept, and how it simplifies bytecode into machine code. Isn't bytecode supposed to be the machine language (0s and 1s)?
8 odpowiedzi
+ 3
The bytecode isn't necessarily 1s and 0s. The java compiler turns your source code into its own specially formatted bytecode which is a combination of different predefined characters. Now the JVM acts as an interpreter that simplifies the bytecode into machine code.
Now you must know that the JVM is separate for different platforms. And it creates virtual machine/environment to run the same java bytecode anywhere. This way java gives the effect of "write once, run anywhere"
+ 3
Every operating system has its own machine language The java compiler simply provides us with the intermediate(bytecode) code which jvm can convert into any of machine code based on your Operating System.
+ 2
OK machine language, is machine specific instructions in binary. The jvm is a virtual machine, and byte code is machine language specific to the jvm. The jvm translates byte code to native machine language for that specific platform. This is done at runtime, it occures when u run the java app. JAVA is a compiled because it targets a machine, a virtual machine. The byte code at runtime is note recompiled, it's only translated to native machine language; True good jvm's still may preformed native architecture specific optimizations but the byte code is not changed because of this.
+ 1
Exactly. So the code you write in Java is automatically converted to Java bytecode when it is compiled and then passed through the JVM which tells the computer that the JVM is running on what to do with that code.
+ 1
first u have to understand why bytecode is created in java unlike in c,c++.The thing is c,c++ is a platform dependent I.e it is not able to run in different os .so Java is 2 level compiler.first source code is converted into byte code.This byte code is converted into machine code by JRE.JRE is different for different platforms.
0
Love this!! Between the user friendly app and the knowledgeable folks who post comments, very good. I just want to say im such a noooob haha. Must say I tried to learn computer language before gave up was so overwhelming. I never expected to find this app! IM FINALLY BEGINNING TO UNDERSTAND!!! Thank you everyone!!
0
Java program execution follows 5 majors steps:
Edit
Compile
Load
Verify
and Execute
1. Edit - Here the programmer uses a simple editor or a notepad application to write the java program and in the end give it a .java extension
2. Compile - In this step the programmer gives the javac command and the .java files are converted into bytecode which is the language understood by the java virtual machine (and this is what makes java platform independent language). Any compile time errors are raised at this step
3. Load - The program is then loaded into memory. This is done by the class loader which takes the .class files containing the bytecode and stores it in the memory. The .class file can be loaded from your hard disk or from the network as well
4. Verify - the bytecode verifier checks if the bytecode loaded are valid and do not breach java's security restrictions
5. Execute - The JVM interprets the program one bytecode at a time and runs the program
0
byte code is not 0's and 1's it converts byte code to 0's and 1's