What is java virtual machine and what does it have to do with Java?

8,024

Solution 1

What is the JVM?

The Java Virtual Machine (JVM) is an interpreter that runs Java bytecode.

When you compile a Java program the output is Java bytecode which can then be executed by the any computer that has a native JVM.

In the Java programming language, all source code is first written in plain text files ending with the .java extension.

Those source files are then compiled into .class files by the javac compiler.

A .class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine (JVM).

The java launcher tool then runs your application with an instance of the Java Virtual Machine.

enter image description here

Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris™ Operating System (Solaris OS), Linux, or Mac OS.

Some virtual machines, such as the Java SE HotSpot at a Glance, perform additional steps at runtime to give your application a performance boost. This includes various tasks such as finding performance bottlenecks and recompiling (to native code) frequently used sections of code.

enter image description here

Source About the Java Technology


So how do I download a JVM?

The Java Runtime Environment (JRE) includes a JVM.

  • If you are just running Java programs the JRE is sufficient.

The Java Development Kit is a superset of the JRE (so it also includes a JVM). It also contains other tools required to develop Java programs, for example a compiler.

  • If you are developing Java programs you should download the JDK.

You can download both the JRE and the JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html


So why am I getting an error message?

The version of the JVM you already have installed is too old for the version of Eclipse you are trying to install.

In order to get a newer version you need to install either a newer JRE or a newer JDK, which both include a JVM.


I installed the latest java from this page anyway but the message is still there

A potential solution to your problem might be to uninstall Java6 (provided by Apple itself) and only have Java7 installed in your system. This only applies in case you have no applications that desperately need the old Java6 version to be installed.

To remove the Apple-like Java6 installation open a Terminal and:

sudo rm -rf /System/Library/Java/JavaVirtualMachines/1.6.0.jdk

After this step you should only have Java7 by Oracle installed in your system. To verify, open another terminal and do a:

java -version 

It should display something like "java version "1.7.0_XX" where XX is the current update version of the Java7 installation. If not: proceed with the next step.

Redefine the JAVA_HOME variable (to support IDEs like Eclipse and other developer tools...), which helps detecting where the "active" Java installation is situated in your system. Open a terminal and (Note: replace XX first!):

sudo rm /Library/Java/Home

sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_XX.jdk/Contents/Home /Library/Java/Home

Afterwards, a fresh installation of Eclipse should detect Java7 in your system and should work with this version out of the box. You can modify an installed Eclipse to use this installation by navigating in Eclipse to:

Preferences -> Java -> Installed JREs.

Then remove the old Java6 system entry AND add new path (see above) with the name Java7.

Source answer to I installed Java 7 but Eclipse keep saying that 1.6 is not suitable for this product by MWiesner

Solution 2

there is this JDK which is JVM plus other stuff for java development http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html That message you have a screenshot of suggests that you already have JVM 1.6 but need 1.7 or greater. But you don't need the JDK it's quite big.

This link that says free java download, would include the JVM
https://java.com/en/download/ A google says JRE includes JVM plus some classes. The other option is the JDK which includes JVM plus some tools for developers. You only need the JRE unless you're a developer than you can just get the JDK. Either way you'll get the JVM.

Try going to whatever part of the mac involves listing programs, and see if you can remove version 1.6 It seems the program that gives that message is seeing only java 1.6 and not the latest version. You can check your path echo $PATH and try to find out what java version is in your path.

this command works in windows with gnuwin32

C:\Users\harvey>java -showversion 2>&1 | head -n 1
java version "1.8.0_11"

I think it works on a linux or mac too

$ java -showversion 2>&1 | head -n 1
java version "1.8.0_11"

or just java -showversion and look at the first line of output and you'll see the version.

Share:
8,024

Related videos on Youtube

shenkwen
Author by

shenkwen

Updated on September 18, 2022

Comments

  • shenkwen
    shenkwen over 1 year

    I was trying to install eclipse on my Macbook Air. When I run the installer I get this message

    enter image description here

    There seems no official page dedicated to JVM like other Apps. When I search "install jvm" I was lead to a "download java" page.

    I installed the latest java from this page anyway but the message is still there, which makes me more confused.

    Questions are:

    1. If the JVM is meant to enable Java "anywhere", shouldn't it be already installed after I install the latest Java?

    2. When I search around google presents a lot of pages, none of them looks like a genuine page, I even search jvm in java.com, but nothing useful comes up.

      Why is it so hard to find such a popular tool and where exactly should I go to download the JVM?

    • Ramhound
      Ramhound about 8 years
      It is Java....What has your research shown
    • DavidPostill
      DavidPostill about 8 years
      @ranhound It's not so obvious for someone who is not an expert on Java technology. In addition, fixing the error is even less obvious. I had to go look up instructions for OSX (fortunately they were on Stack Overflow)
  • shenkwen
    shenkwen about 8 years
    I tried those commands but they didn't work. After running the command which is supposed to uninstall java 1.6, I ran java -version and it still showed java 1.6. At last, I install latest jdk from the oracle page and the version became 1.8. Running eclipse now.