Java virtual machines mac

How to install Java on Mac (macOS 10.14 & 10.15)

Java is one of the most used programming languages for backend and creating different type of applications ( web application, mobile applications, desktop applications, and many more). It supports all the major operating systems such as Windows, Linux, Solaris, and MacOS. In this topic, we will see how to install Java on mac and its different variations.

Before proceeding further, let’s have a look at the quick index of the topic:

System Requirements to install Java on mac

The system requirements and considerations for installing the JDK and the JRE on macOS are as following:

Important points to be considered while installing Java on MacOS:

A computer running macOS and having administrator privileges.

Java can not be installed for a single user instead it is installed systemwide for all users.

The JDK package contains JRE by default. However, the current JRE version will not be replaced with the lower version of JRE.

Installing the JRE will not contain the JVM or other Java libraries for creating applications. It can only be used to run the Java apllications. See the difference between JRE, JDK, and OracleJDK.

Hardware requirements:

The following requirements should be meet to install Java 7 or later versions:

  • Intel-based Mac running versions 10.7.3 and above
  • Administrator privileges
  • A 64-bit browser (e.g., Safari)
  • 32-bit browsers do not support Java 7 and later versions on the Mac platform

Determining the JRE Version Installed on macOS

There can be only one JRE version on the system. Installing the JRE will replaces the previous version. However, it will not replace with the older versions.

The JRE version can be determned by the following ways:

Visit System Preferences->Other section->Java . This will start the Java Control Panel, after this, click on About to display the version information.

Enter the following command on terminal:

% /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version

The above command will display the installed Java version.

Determining the Default JDK Version on macOS

To start a Java application, the system uses the default JDK version. It is possible JRE may have the a different version that the JDK.

There can be multiple versions of the JDK, but, the JRE version can be only one (latest).

To determine the installed Java version, execute the below command:

The above command will display the output something like this ( for Java 10):

java version "10.0.2.1-ea" Java(TM) SE Runtime Environment (build 10.0.2.1-ea+13) Java HotSpot(TM) 64-Bit Server VM (build 23.2-b04, mixed mode)

To change the default version version of Java, either specify the full path, or use the java_home tool as follows:

/usr/libexec/java_home -v 10.0.2.1 --exec javac -version

Installing the JDK on macOS

Читайте также:  Php html file editor

The JDK package by default contains the associated JRE versions. The JavaFX SDK and Runtime are also packaged into the standard JDK package.

Follow the below steps to install Java on MacOS:

Download the JDK .dmg file from Here, or by executing the below command:

jdk-10.interim.update.patch-macosx-x64.dmg

before downloading the file you must accept license agreements.

After the successfull Double click on the ‘.dmg’ file to start the installation process.

Next, you will see a finder window having the name of the ‘.pkg’ file. Click on the ‘.pkg’ file to proceed the installation process:

In this step, you will see a Introduction window, click Continue.

You will see a installation type window, Click Install to continue.

In this step you will see a window having a message “Installer is trying to install new software”. Type your administrator password to allow this.

Enter the Administrator user name and password and click Install Software.

The downlaoded Java version is installed on your machne and confirmation window is displayed.

Installing the JRE on macOS

Follow the below steps to install the JRE on an macOS platform:

Download the JRE .dmg file, by executing the below command:

jre-10.interim.update.patch_osx-x64_bin.dmg

Accept the license agreement.

Next, double-click on the .dmg file and launch it.

In this step, you will see a finder window appears having ‘.app’ file.

Double-click on the Java 10.app icon, it will start the installation process.

The installation process will display the Welcome window, Click Next to continue the process.

Hence, the downloaded JRE version is installed and a confirmation window is displayed. Click Close to complete the process.

Installing By Homebrew

To install By Homebrew package manager, follow the following steps:

Step1: Install Homebrew and update it, and download openJDK package by executing the below commands:

brew update Add adoptopenjdk/openjdk. brew tap adoptopenjdk/openjdk

Step2: Find all available JDK versions by executing the below command:

The output will be something like this:

 ==> Casks adoptopenjdk adoptopenjdk12 adoptopenjdk13-openj9 adoptopenjdk8-openj9-jre adoptopenjdk10 adoptopenjdk12-jre adoptopenjdk13-openj9-jre adoptopenjdk8-openj9-jre-large adoptopenjdk11 adoptopenjdk12-openj9 adoptopenjdk13-openj9-jre-large adoptopenjdk8-openj9-large adoptopenjdk11-jre adoptopenjdk12-openj9-jre adoptopenjdk13-openj9-large adoptopenjdk9 adoptopenjdk11-openj9 adoptopenjdk12-openj9-jre-large adoptopenjdk8 oracle-jdk adoptopenjdk11-openj9-jre adoptopenjdk12-openj9-large adoptopenjdk8 oracle-jdk-javadoc adoptopenjdk11-openj9-jre-large adoptopenjdk13 adoptopenjdk8-jre sapmachine-jdk adoptopenjdk11-openj9-large adoptopenjdk13-jre adoptopenjdk8-openj9

Step3: Select Java versions like Java 8, 9, 10, 11, 12, 13 by executing the one of the following commands:

brew cask install adoptopenjdk8 brew cask install adoptopenjdk9 brew cask install adoptopenjdk10 brew cask install adoptopenjdk11 brew cask install adoptopenjdk12 brew cask install adoptopenjdk13

Step4: for example to install Java 8 and 11, execute the below commads:

brew cask install adoptopenjdk8

brew cask install adoptopenjdk11

To display the loaction where Java is installed, execute the below command:

Читайте также:  Upload files with python

The above command will display the output something like this:

Matching Java Virtual Machines (2): 11.0.6, x86_64: "AdoptOpenJDK 11" /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home 1.8.0_242, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Homebrew will install the JDK at Mac’s standard folder for Java “/Library/Java/JavaVirtualMachines/”.

Verify the installation, by executing the below command:

openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed

By default, Mac takes the Higher version of Java.

Version Switching

To change the default version of Java create or edit the “~/.bash_profile” with the text editor of your choice like vim or nano, export JAVA_HOME variable to the specified JDK we want to use on Mac.

Execute the below command:

~/.bash_profile:

export JAVA_HOME_8=$(/usr/libexec/java_home -v1.8) export JAVA_HOME_11=$(/usr/libexec/java_home -v11) export JAVA_HOME_14=$(/usr/libexec/java_home -v14) # Java 8 export JAVA_HOME=$JAVA_HOME_8 # Java 11 # export JAVA_HOME=$JAVA_HOME_11

The above script will make the Java 8 as default Java version.

Uninstalling the JDK on macOS

To uninstall the JDK on macOS, Navigate to “/Library/Java/JavaVirtualMachines”. Remove the directory whose name matches the following format:

/Library/Java/JavaVirtualMachines/jdk-interim.update.patch.jdk

For example, to uninstall Java 10, execute the below command:

Note: Do not try to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time that you perform an update of the OS.

Uninstalling the JRE on macOS

To uninstall JRE, Navigate to “/Library/Internet Plug-Ins”. From here, remove the JavaAppletPlugin.plugin directory.

Now, navigate to “/Library/PreferencePanes”.

Источник

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

enter image description here

I was trying to install eclipse on my Macbook Air. When I run the installer I get this message 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?

@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)

2 Answers 2

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.

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.

So how do I download a JVM?

The Java Runtime Environment (JRE) includes a JVM.

Читайте также:  Cellpadding for table css

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.

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:

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.

Источник

Оцените статью