This document was written by CS 290W TA Joshua Kay and was last modifiedWe want a language that can run on any machine, that the machine interprets.
"Interpreted" means that the computer looks at the language, and then turns it into native machine language.
Interpreted versus compiled
-Interpretation happens at runtime, compiling happens when the writing of the program is finished.
-Interpreted languages can run across platforms, compiled languages are native to one computer
But Java is compiled, too. What's going on?
Java is both compiled AND interpreted. What does this mean?
Java doesn't actually run on a PC or a Sun or a Mac. Java runs on the Java Virtual Machine (JVM)
When C++ code is compiled, it is compiled into Machine Language, or Native Binary Code, which is understood by the computer it was compiled on.
When Java code is compiled, it is compiled into Java ByteCode, which is understood by the JVM.
So, any computer which has the JVM installed can understand Java ByteCode.
example: I don't know German, and my new German friend doesn't know English. However, we both have a working knowledge of Spanish. So we can speak to each other. he can write something that I can understand, or vice versa.
How this works
We Install the Java Virtual Machine on a PC, and also on a Unix workstation.
We write a Java program on the PC, and compile it. This creates Java ByteCode.
We then run the program (via the Web) on the Unix workstation. The JVM on the Unix workstation Interprets the Java ByteCode, and creates Native Machine Language which the computer then executes.