Что такое виртуальная машина Java и как она связана с Java?

4059
shenkwen

Я пытался установить Eclipse на моем Macbook Air. Когда я запускаю установщик, я получаю это сообщение

Что такое виртуальная машина Java и как она связана с Java?

Кажется, нет официальной страницы, посвященной JVM, как другие приложения. Когда я искал "установить jvm", я попал на страницу " скачать Java ".

Я установил последнюю версию Java с этой страницы в любом случае, но сообщение все еще там, что делает меня более запутанным.

Вопросы:

  1. Если JVM предназначена для включения Java «где угодно», разве он не должен быть установлен после того, как я установил последнюю версию Java?

  2. Когда я ищу в Google много страниц, ни одна из них не выглядит как настоящая, я даже ищу jvmна java.com, но ничего полезного не получается.

    Почему так сложно найти такой популярный инструмент, и куда именно я должен пойти, чтобы загрузить JVM?

1
Это Java .... Что показало ваше исследование Ramhound 8 лет назад 0
@ranhound Это не так очевидно для тех, кто не является экспертом по технологии Java. Кроме того, исправление ошибки еще менее очевидно. Я должен был посмотреть инструкции для OSX (к счастью, они были на [так]) DavidPostill 8 лет назад 0

2 ответа на вопрос

5
DavidPostill

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

Я пробовал эти команды, но они не работали. После запуска команды, которая должна удалить java 1.6, я запустил java -version, и он все еще показывал java 1.6. Наконец, я установил последнюю версию JDK со страницы оракула, и версия стала 1.8. Запущено затмение сейчас. shenkwen 8 лет назад 0
1
barlop

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.