Java is platform independent - What is platform independence?
I will be posting java concepts .Keeping it brief . I will not be posting something like what is java ? . I will jump to key concepts what I learn everyday .
So we know java is platform independent ..what is platform independence ?
->Developing you app in one operating system and being able to run in another operating system without any modification is called platform independent ..
1.Java compilation process:-So we all know that while developing java applications or programs we need something called Jdk . so what it contains. What the jdk contains ->the jdk contains the developing tools and the jre,java run-time environment in broad sense . More precisely , it consists of the jre , compiler ,debugger and developers tools .
2.Jre contains the JVM , libraries and other components
3.Now, the JVM consists of jit-just in time compiler , this guy does the job of converting bytecode into machine instructions. Now , what that's dont worry we'll get back to that .Just keep it with you .
4. Now , we are actually going to start .. Sorry for the delay ..
5.So you got your source code , we compile it using the javac compiler .What we get is bytecode or .class file which is the same for all platforms .This compiler is also machine Independent.
6.Now ,when you try to run your program .The .class file of the main class (the class that contains main ) is passed to the JVM . This actually has three stages :-
I. class loader :- The main class and related classes are loaded with the help of class loader .class loader is actually an object . p.s.:- let's not get too deep Now.If you are interested you can check .
Ii.byte verification:- The bytecode of the loaded classes is verified whether it does dangerous things . If it does so it is not allowed to be loaded .
Iii.Intrepreter/JIT compiler :- Finally after loading and verification process the interpreter coverts our bytecode into machine code 0 & 1 which now your computer can understand line by line and also executes line by line in the CPU .The jit actually does some optimization and passes the bytecode to the interpreter for it to do its job.
4.byte code verification
6. 0's and 1 's
P.s:- Always feel free to point out the inaccuracies and share your wisdom.
Requesting you to write the tutorials in our Tutorials App, for better discovery and promotion. We groups could be used for discussions / questions and answers.
I didnt knew about that before .Okay now I will continue there