I am using M1 Mac OS11.5.2.
I’ve already downloaded zulu.jdk and zulu.jre, in “/Library/Java/JavaVirtualMachines”.
I also exported the PATH.
When I type
sudo apt update
I get this:
The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
Please visit http://www.java.com for information on installing Java.
I hope some kind person could tell me the solution.
APT is for Linux
You can add a similar package-management tool to macOS developed by a third party: Homebrew.
I have not used Homebrew myself, but some folks are big fans.
For only installing JDKs, I would consider this tool to be overkill, and would recommend SDKMAN or manual installers as discussed further down. But if you might want to install other kinds of software besides just JDKs in this manner, then consider Homebrew.
SDKMAN is a tool rapidly growing in popularity. As a collection of shell scripts, SDKMAN works across any Unix-oriented host OSes including macOS, BSD, Linux, and more.
SDKMAN works to manage the downloading, installing, and setting as default any of the many JDK offerings from a variety of vendors. This command-line tool has a simple well-defined API.
I only recently decided to avail myself of this tool. I expect this to be my new preferred way to manage my JDKs on my Macs and BSD servers.
To install Java, I use an installer app for macOS from Adoptium or Azul Systems, or from any of the several other vendors providing distributions of Java such as BellSoft, Amazon, Microsoft, Oracle, SAP, Red Hat/IBM, Pivotal, etc.
To update I simply:
- Delete the existing JDK found in
- Run a freshly-downloaded installer.
This approach is a manual operation. And this requires the Mac’s admin password.
So for mass updates across many computers I can imagine that shell-scripting with SDKMAN would be a better solution. Also, some JDK vendors are releasing installers that can be controlled by a shell script.
Answered By – Basil Bourque