Originally posted by Muralidhar Gandepalli:
HI! can anyone explain me what is done exactly once i type
1)javac mypro.java
and later
2) java myporg
It would help me alot if some gives me exact details i.e what are roles played by JVM,JTI and interpreter ? at what times.
Thanks in advance.
Murali
When you type javac MyProg.java, the java compiler converts your java source file to 'bytecode'. This is the same whatever machine you compile it on (aside from slight differences between compilers).
Then, you run java MyProg. To run your program, the JVM (which is written specifically for the platfor it's running on) reads the bytecode and interprets it, line by line, and works out what to do, passing native (platform-specific) instructions to the processor accordingly.
The JIT (just-in-time) compiler, which is'nt included in all JVMs, is something used to potentially increase performance of a java program. Instead of interpreting the bytecode line by line, when the JVM reads in a bit of code, the JIT compiles it to native machine code. This takes a bit of time, but next time the bit of code is happened upon, there is a native version of it, so it doesn't have to be interpreted and executes faster.
And then it says "hello world!" on your screen.