+ 1
Compilation and Execution of a Java Program
I've been programming in java for almost 2 years and I still wonder how does a java code (or any other compiled language) is being executed from start to end. All I know is that the java code is being translated to byte code and then the computer's cpu executes the commands. I'd like to have a more detailed walk through that consists of the purpose of the JVM, JAVAC etc... Thanks.
4 Respuestas
+ 4
as far as i know..
jvm is just a virtual machine (think it like an os running in virtual box just for intuition)
now you write a javacode and compile with javac .. now what it does is it just compiles the code to a jvm's bytecode (its understandable only by your jvm and not the os )
now when you run your code via jvm .. this jvm parses the byte code and works as an interpreter ....
now you may say why not just take the source code and do directly interpretation like how python does..
well its just to improve performance a bit..
running a small code would be ok but think of huge projects which takes even hours to build..
a more detailed information can be found here : https://dev.to/sivantha96/java-under-the-hood-3071#:~:text=The%20Java%20compiler%20transforms%20the,be%20executed%20using%20the%20JVM.
+ 3
normal byte code is there any step like that ?! not sure ..
ain't actually java guy .. i know from bird eye view ..
maybe read that article...
0
Prashanth Kumar so does it go like this?
Java code -> JVM byte code-> normal byte code
0
Ok, So for now let's say that the JAVAC translates the code to byte code, and the byte code runs on the java virtual machine (JVM). 😀