Here's what sparked off this question in me: Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris TM Operating System (Solaris OS), Linux, or Mac OS. Some virtual machines, such as the Java HotSpot virtual machine, perform additional steps at runtime to give your application a performance boost. This include various tasks such as finding performance bottlenecks and recompiling (to native code) frequently used sections of code. -The Java Tutorials
Well, my question is: Is this the sole reason why JVM was created - for making your programs portable? Can't we take the same approach without having a JVM? Why not have different compilers (that compile source code directly to machine code) for different platforms? (Of course, then we would be faced with two situations 1. we need to distribute the source code to the end users; could be a security issue - but we could encrypt the source code or restrict access to the source code except for compiling purpose.
2. the end users would need to recompile the source code - at least initially; this could delay program start up.)
I feel that the creation of the JVM was more a result of taking the 'seperation of concerns' approach than just to address the portability issue. I presume the designers of Java wanted to give the Java programmer a single interface by providing a compiler whose only job would be to compile the source code to an intermediate bytecode. And they encapsulated the task of making sense of the bytecode in the JVM. Shouldn't we also highlight this design strategy being the cause of the JVM apart from portability? [ April 22, 2008: Message edited by: Gaura Hari ]
Besides all the things others have said, the fact that the JVM is essentially independent of the Java language means that any language that can be compiled to JVM bytecode can be run on the JVM. [ April 22, 2008: Message edited by: Garrett Rowe ]
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joined: Apr 09, 2008
Thanks to all of you for spending your time to think along.
subject: What doew JVM bring to the table - portability only?