Every programmer talks about Java Virtual Machine (JVM) and JVM is everywhere. But most people who knows Java do not really know what a JVM is, how it is implemented and why it is very popular. I will try my best to explain what I understand about JVM in this post. All comments, suggestions and corrections are welcomed.
What is Java Virtual Machine?
Like the name said, it's a virtual machine. It's a machine that executes Java Codes. It's a light weight and portable program that comes with all Java download. If you ever used VMWare to run an OS which is different from the one installed in your machine, then it'll be easier for you to understand how JVM works. In VMWare, you don't need to install the other OS, you create a virtual environment in which the OS runs. Same concept is here, you don't need a certain hardware or programs for your Java programs to run. All you need is a JVM and all the different Java programs will run on your machine.
Virtual Machine Implementation
Java has become a very popular language because of its JVM. Java itself is a high level programming language. If you write a Java program and ask your computer to run, it won't understand what it means. There are only 0's and 1's in the lowest level of our implementation. So, there's a way to convert what programmers write to what machines understand and that is where compilers come in. Those converted codes are called machine codes. When a Java program is compiled, it is converted to bytecode. Bytecodes are machine independent and can be further compiled in machine codes. Because of its machine independence, a Java program can be run anywhere as long as you have Java Runtime Enviroment installed in your computer. JRE is a program that takes of Java bytecodes according to the machines. All JRE comes with JVM. Since programmers do not have to worry about different machines, they can focus more on their programs.
You must be familiar with Java Applets from different websites. Because of JVM, those developers don't have to worry about different browsers, OS and hardware when creating Java applets. That's why Java has been a popular programming language and JVM has been a popular environment.
No comments:
Post a Comment