Why do JAVA programmers code for a non-existent computer?

Old 4 Comments on Why do JAVA programmers code for a non-existent computer? 11

I assume everyone on geekbraindump.com knows that computers don’t understand any human language — English, Swahili, Chinese e.t.c. They understand what’s called Machine Language which is a sequence of Zeros and Ones. Well when you code a program in high level programming languages such as JAVA don’t you, have to compile it into Ones and Zeros? Well that thought is incorrect.

Java programs are instead compiled into what is called “Java bytecode” instead of machine language. This is what the Java Virtual Machine (JVM) understands. There is no reason why Java bytecode could not be used as the machine language of a real computer, rather than a virtual computer. The use of a virtual machine makes possible one of the main selling points of Java: the fact that it can actually be used on any computer.

So Java bytecode is a machine language for a Java Virtual Machine which is a non-existent computer. How come Java programs still run on any computer platform e.g windows, mac, and linux?

Well all that the computer needs is an interpreter for Java bytecode. Once a computer has a java bytecode interpreter, it can run any Java bytecode program technically written for JVM.

The bottom line is: if you want to run a java program on a windows computer, use Java Interpreter for windows. If you want to run a java program on Mac computer, use Java Interpreter for Mac OS and finally if you want to run a java program on a Linux computer, use Java Interpreter for linux.

Java bytecode interpreters are usually packaged in Java Run Time Environments (JRE) or Java Development Kit (JDK)

I know most of you are confused 🙂

Author

William Oneb

William Oneb is Java Programmer, Android Developer, Web Designer and is currently studying Objective C. He has developed at least 3 wordpress plugins/widgets. He is interested in iOS development too.

Related Articles

4 Comments

  1. Joey Graziano June 13, 2014 at 1:00 pm

    QUESTION: Since Java has the virtual machine, does this mean that Java will run slower and require more resources than a native compiled language such as C# or objective C?

    I believe theoretically the answer should be yes. But based off your experience, what say you?

    • Nickolas Freitas June 13, 2014 at 11:34 pm

      Yes it does. One of the most common examples is C vs Java. With C, you need to compile the source code to a specific architecture which means it isn’t portable; unlike Java’s bytecode that is portable. With C, the ultimate product runs much faster and is more efficient, since you only run the code you wrote; unlike Java that interprets your code, while having to run JVM in the background.

    • William Oneb June 16, 2014 at 6:51 am

      That’s an argument Joey but I love the beauty of writing a program that’s gonna run across all the platforms and remember every programming language has got its pros and cons. Anyway, Java programs are slower and that’s why the language is not effective in programming computer games.

    • ebey July 4, 2014 at 10:13 am

      PROBABLE ANSWER: dude if u notice java contains very less input subroutines unlike c and c++,more likely used for apps and in fansy websites..to program basically ..and os are programmed by c..were user interaction is more with pc.. because of its selective usage..the program essentially or normally in program world doesnt process much input data… so speed of conversion really doesnt matter that much…

Leave a comment

Back to Top