Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The reason for JVM existence

Tags:

java

jvm

I am educating myself in the theory of programming languages and I wonder, why exactly do we need a Java Virtual Machine or any virtual machine at all for that matter? What are the fundamental reasons?

Is it solely for making it multi-platform? If so, why cannot we just have a platform independent language and different compilers for different platforms?

like image 481
lishaak Avatar asked Apr 05 '14 07:04

lishaak


People also ask

What is JVM and why is it needed?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation.

Does JVM exist?

The JVM in a nutshellThis computer does not exist as actual hardware, and does not even have an operating system. It is a hypothetical computer platform. Next, as discussed above, a computer needs a machine language to execute programs, so the JVM also has its own machine language which is called Java bytecode.

Why JVM is not physically exist?

JVM does not physically exist because, unlike your computer, which exists in the form of a physical box with motherboard and chips, the JVM exists in memory. The java.exe program that you run when you try to "execute" your java class implements a "virtual" computer aka the "virtual machine".

What is the reason of Java platform independent?

Java is platform-independent because it uses a virtual machine. The Java programming language and all APIs are compiled into bytecodes. Bytecodes are effectively platform-independent. The virtual machine takes care of the differences between the bytecodes for the different platforms.


1 Answers

In their 1996 whitepaper The Java Language Environment, the Java team at Sun states the following design goals for the Java Language:

The design requirements of the Java TM programming language are driven by the nature of the computing environments in which software must be deployed.

The massive growth of the Internet and the World-Wide Web leads us to a completely new way of looking at development and distribution of software. To live in the world of electronic commerce and distribution, Java technology must enable the development of secure, high performance, and highly robust applications on multiple platforms in heterogeneous, distributed networks.

Operating on multiple platforms in heterogeneous networks invalidates the traditional schemes of binary distribution, release, upgrade, patch, and so on. To survive in this jungle, the Java programming language must be architecture neutral, portable, and dynamically adaptable.

The system that emerged to meet these needs is simple, so it can be easily programmed by most developers; familiar, so that current developers can easily learn the Java programming language; object oriented, to take advantage of modern software development methodologies and to fit into distributed client-server applications; multithreaded, for high performance in applications that need to perform multiple concurrent activities, such as multimedia; and interpreted, for maximum portability and dynamic capabilities.

A bit further down, they address the reasons for using an interpreter in greater detail:

The Java interpreter can execute Java bytecodes directly on any machine to which the interpreter and run-time system have been ported. In an interpreted platform such as Java technology-based system, the link phase of a program is simple, incremental, and lightweight. You benefit from much faster development cycles--prototyping, experimentation, and rapid development are the normal case, versus the traditional heavyweight compile, link, and test cycles.

While the Java Compiler is strict in its compile-time static checking, the language and run-time system are dynamic in their linking stages. Classes are linked only as needed. New code modules can be linked in on demand from a variety of sources, even from sources across a network. In the case of the HotJava Browser and similar applications, interactive executable code can be loaded from anywhere, which enables transparent updating of applications. The result is on-line services that constantly evolve; they can remain innovative and fresh, draw more customers, and spur the growth of electronic commerce on the Internet.

like image 170
meriton Avatar answered Nov 05 '22 00:11

meriton