images 2 - What exactly is the Java Virtual Machine and what is it used for
Computers Programming Smartphones

What exactly is the Java Virtual Machine and what is it used for

So as we learnt in the previous tutorial machine language is the only language a computer understands and machine codes when written can be run directly by the computer because that it language. thoughhhh

High level languages which is the programming language almost all programs are written in, cannot run directly by a computer because the computer doesn’t understand high-level languages so much.

download 1 1870623071. - What exactly is the Java Virtual Machine and what is it used for

For a computer to understand a high-level language, it has to be translated to it own language which is machine language. There are a couple of ways this could be done. It could be compiled by something called a compiler.

What a compiler does is convert the entire code into an executable machine code and feeds it into the computer. But there’s a catch here, every computer has it own different type of machine language which means the compiled code for one machine won’t run on another, it has to be recompiled by it own compiler.

Another way of executing your program is by interpreting it with something called an interpreter. Unlike the compiler which takes the entire code and converts them all at once before feeding it to the computer, the interpreter on the other hand does it differently.

The interpreter translates your code by running it instruction-by-instruction and not all at once. It is sometimes considered better by some people because if it encounters an error it simply stops working which means you know where the error is on.


But if it were to be a compiler, after it compiles the entire code and then encounters an error it usually very difficult and stressful to spot the problem.

Java Virtual Machine (JVM) was a very smart idea that was developed by the creators of java, what the JVM does is that it takes your java code and turns it into something called a bytecode.

The bytecode is much like a machine language that can run ln any computer all that is needed by the computer is just an interpreter for java bytecode.

This amazing feature is what makes java a “WORE” write once run everywhere language. So if you write a java code you don’t have to bother yourself about re-writing a java code to be compatible by a computer.

Don’t forget to share this if you liked it and also if you’ve got any questions or suggestions don’t hesitate to let us know down in the comment section. Also don’t forget to read read the next one on your programming journey.➡

Hello there I'm a tech-inclined geek, and I've always been a huge fan when it comes to anything tech, so I decided to share my knowledge with the online community and also share some of the latest buzzing news in the tech biosphere. i am dedicated to providing you guys with the best news updates. email: [email protected]

Don't forget to leave a Reply