Mac os установка java 11

How to install Java JDK on MacOS

Java is a general-purpose, secure, robust, object-oriented language developed by Sun Microsystems in 1990. Java is portable which means it follows to write once run anywhere paradigm. Many of the useful applications are built on Java and required a Java runtime environment. If you are preparing your system for developing new Java applications, you need to install JDK on your machine.

In this blog post, you will learn to install different-2 Java versions on macOS using Homebrew.

Pre-Requisites

Before starting the installation of Java using this tutorial you must have the following prerequisites

  • Terminal: You must have Mac Terminal access and little knowledge about working with the terminal application. Ao login to your Mac system and open terminal
  • Homebrew: This tutorial relies on Homebrew, So you must have homebrew installed. Homebrew can be installed with a single command. You can follow these instructions to install Homebrew

How to Install Java on MacOS

The Homebrew contains the latest stable java version along with the LTS release Java 8, 11 LTS, and Java 17. Follow the below steps to install the specific version of Java or all the available Java versions on your macOS system.

brew search openjdk ==> Formulae openjdk ✔ [email protected] [email protected] [email protected] jd mdk cdk

As you know that Brew’s “openjdk” formulae always refer to the latest version. You can install it with the following command.

Brew installation of OpenJDK doesn’t set reference than Celler directory. For the system, Java wrappers to find this JDK, symlink it with:

sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk 

Generally, the applications required some old or stable Java versions. So instead of installing default (latest) Java, install specific Java by its version number. Here Java 8, and 11 are the LTS versions. Use one of the below options to install the required Java version. If required, You can also install all the versions on a single system:

sudo ln -sfn /usr/local/opt/[email protected]/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-1.8.jdk 
sudo ln -sfn /usr/local/opt/[email protected]/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk 
sudo ln -sfn /usr/local/opt/[email protected]/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk 
java -version openjdk version "11.0.16.1" 2022-08-12 OpenJDK Runtime Environment Homebrew (build 11.0.16.1+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.16.1+0, mixed mode)

Setup JAVA_HOME and Switching Version

The /usr/libexec/java_home command returns a path suitable for setting the JAVA_HOME environment variable. It determines this path from the preferred JVMs in the Java Preferences application. Use the below steps to configure JAVA_HOME environment variable. Also, know about switching to the default Java version.

Читайте также:  Php framework which is best

    Use java_home command with -V option to list all the JVM configured on your macOS.

/usr/libexec/java_home -V Matching Java Virtual Machines (4): 18.0.2.1 (x86_64) "Homebrew" - "OpenJDK 18.0.2.1" /usr/local/Cellar/openjdk/18.0.2.1/libexec/openjdk.jdk/Contents/Home 17.0.4.1 (x86_64) "Homebrew" - "OpenJDK 17.0.4.1" /usr/local/Cellar/[email protected]/17.0.4.1/libexec/openjdk.jdk/Contents/Home 11.0.16.1 (x86_64) "Homebrew" - "OpenJDK 11.0.16.1" /usr/local/Cellar/[email protected]/11.0.16.1/libexec/openjdk.jdk/Contents/Home 1.8.0_345 (x86_64) "Homebrew" - "OpenJDK 8" /usr/local/Cellar/[email protected]/1.8.0+345/libexec/openjdk.jdk/Contents/Home /usr/local/Cellar/openjdk/18.0.2.1/libexec/openjdk.jdk/Contents/Home

Источник

Mac os установка java 11

This topic includes the following sections:

System Requirements for Installing the JDK on macOS

The following are the system requirements for installing the JDK on macOS:

  • Any Intel-based computer running macOS.
  • Administrator privileges. You cannot install Java for a single user. Installing the JDK on macOS is performed on a systemwide basis for all users. Administrator privileges are required to install the JDK on macOS.

Determining the Default JDK Version on macOS

When starting a Java application through the command line, the system uses the default JDK.

You can determine which version of the JDK is the default by entering java -version in a Terminal window. If the installed version is 11 Interim 0, Update 0, and Patch 0, then you see a string that includes the text 11 . For example:

$ java -version java version "11" Java(TM) SE Runtime Environment (build 11) Java HotSpot(TM) 64-Bit Server VM (build 23.2-b04, mixed mode)

To run a different version of Java, either specify the full path, or use the java_home tool. For example:

$ /usr/libexec/java_home -v 11 —exec javac -version

Installing the JDK on macOS

  • macOS x64 systems: jdk- 11 . interim.update.patch _macos-x64_bin.dmg OR jdk- 11 . interim.update.patch _macos-x64_bin.tar.gz
  • macOS aarch64 (64-bit ARM) systems: jdk- 11 . interim.update.patch _macos-aarch64_bin.dmg OR jdk- 11 . interim.update.patch _macos-aarch64_bin.tar.gz

Click Accept License Agreement .

A window appears that displays the message: Installer is trying to install new software. Enter your password to allow this.

After the software is installed, you can delete the .dmg or .tar.gz file if you want to save disk space.

Uninstalling the JDK on macOS

Do not attempt 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.

  1. Go to /Library/Java/JavaVirtualMachines .
  2. Remove the directory whose name matches the following format by executing the rm command as a root user or by using the sudo tool:

/Library/Java/JavaVirtualMachines/jdk- 11 . interim.update.patch .jdk For example, to uninstall 11 Interim 0 Update 0 Patch 0: $ rm -rf jdk- 11 .jdk

Installation FAQ on macOS Platform

This topic provides answers for the following frequently asked questions about installing JDK on macOS computers.

1. How do I find out which version of Java is the system default?

When you run a Java application from the command line, it uses the default JDK. If you do not develop Java applications, then you do not need to worry about this. See Determining the Default JDK Version on macOS.

Читайте также:  Плагин wordpress php mysql

2. How do I uninstall Java?

3. After installing Java for macOS 2012-006, can I continue to use Apple’s Java 6 alongside the macOS JDK for Java 11 ?

If you want to continue to develop with Java 6 using command-line, then you can modify the startup script for your favorite command environment. For bash, use this:

$ export JAVA_HOME=`/usr/libexec/java_home -v 11`

Some applications use /usr/bin/java to call Java. After installing Java for macOS 2012-006, /usr/bin/java will find the newest JDK installed, and will use that for all of the Java-related command-line tools in /usr/bin . You may need to modify those applications to find Java 6, or contact the developer for a newer version of the application.

4. Can I restore Apple Java after uninstalling Oracle Java?

Go back to Apple Java using the following instructions:

  1. Uninstall Oracle Java by deleting the plug-in file. From a command-line, enter: $ sudo rm -rf «/Library/Internet Plug-Ins/JavaAppletPlugin.plugin»
  2. Create a symlink using the following command, entered on a single line: $ sudo ln -s /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin «/Library/Internet Plug-Ins/JavaAppletPlugin.plugin»

5. What happened to the Java Preferences app in Application Utilities?

The Java Preferences app was part of the Apple Java installation and is not used by Oracle Java. Therefore, macOS releases from Apple that do not include Apple Java will not include Java Preferences.

Источник

How To Install Java 11 On Mac

It provides all the steps required to install Java 11 on Mac systems including macOS Sierra, High Sierra, Mojave, and Catalina. Java 11 is an LTS release and it will be supported by Oracle at least till Aug 2024.

In this tutorial, we will discuss how to install Oracle Java 11 on Mac systems. This tutorial provides all the steps required to install the LTS version of Java i.e. Oracle Java 11 officially distributed by Oracle for Mac. It provides the steps required to install Java 11 on macOS Catalina. The steps should be the same for other versions of macOS including Sierra, High Sierra, and Mojave.

System Checks

In this step, we will test whether Java is already installed or not. To do so, open the terminal and type java -version as shown in Fig 1. It shows that Java is not installed on my system and also opens a dialog to get more info.

Now press the OK Button to hide the dialog. It might show the existing version of Java if it is already installed on your system as shown in Fig 2.

Download Java 11

Open the download link to select the available versions as shown in Fig 3. Also, go through the new Oracle JDK License started since April 16, 2019.

Click the Download Option as highlighted in Fig 3. It will ask to accept the License Agreement before starting the download as shown in Fig 4 and Fig 5. It might also ask to login to Oracle before starting the download.

Читайте также:  Csv string to array python

Install Java 11

Double click the DMG file downloaded in the previous step to start installing Oracle JDK 11 on Mac. It will mount the DMG disk and shows the installer as shown in Fig 6 and Fig 7. Make sure that you have gone through the updated License Agreement of Oracle JDK.

Now double-click the installer to start installing Java 11 on Mac.

macOS Catalina — With the release of macOS 10.15, Apple introduced security checks used by the Gatekeeper to verify the content of distributed software. The Gatekeeper might show a security error. You may refer to How To Install Java 8 On Mac to resolve this issue.

The installer shows the Welcome Screen as shown in Fig 8.

Click the Continue Button to start the installation. It provides options to choose the installation type as shown in Fig 9.

You may change the installation location by clicking the Go Back Button. It did not allow me to change the installation location on macOS Catalina. Now click the Install Button to start installing Java 11 on Mac. It also asks for permission to complete the installation as shown in Fig 10.

It shows the success message after completing the installation as shown in Fig 11.

Now unmount the DMG image by right-clicking it as shown in Fig 12.

We can check the JDK version to confirm the installation as shown in Fig 13.

This is all about installing Oracle JDK 11 on Mac systems including macOS Sierra, High Sierra, Mojave, and Catalina.

Switch JDK

It might be required to switch the active Java in case multiple JDKs are installed on the same Mac machine. You can follow How To Switch Java Version On Mac.

Getting started with Java — Hello World

In this step, we will write, compile, and execute our first program in Java using the standard Hello World example.

Now write the first Java program as shown below, save the program as HelloWorld.java and exit the editor. Make sure that the class name and file name are the same.

class HelloWorld  
public static void main( String[] args )
System.out.println( "Hello World !!" );
>
>

Now open the command prompt and navigate to the path where you have saved your Java program. Use the below-mentioned commands to compile and execute the program.

# Compile - Specify file name and extension
javac HelloWorld.java

# Execute - Spicy file name
java HelloWorld

# Output
Hello World !!

These are the easy to install steps required to install Oracle JDK on Mac and write, compile and execute the first Java program.

Summary

This tutorial provided all the steps required to install Oracle JDK 11 on Mac and also provided the steps required to compile and run the first Java program using a simple Hello World program.

Источник

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