tl;dr
/Library/Java/JavaVirtualMachines/
is the correct location for the JVM to be installed. This has been the case for several years now. Many years ago, other locations were used, but no longer.
You have a choice of several vendors to obtain an installer app to install a Java implementation on your Mac. Download an installer to run locally and then discard, as you commonly do for many apps.
Your Question mentions JavaFX/OpenJFX. You might find it convenient to use a Java implementation that comes bundled with the OpenJFX libraries, such as LibericaFX from BellSoft or ZuluFX from Azul Systems.
Use the Installer, Luke
Other answers suggesting the Homebrew package manager seem a bit extreme to me. I am sure Homebrew has some good uses. But to simply run Java, or do Java programming, installing Homebrew is a needless extra step. Installing Homebrew (package manager) for the single goal of obtaining Java is like building a landing strip to park your car instead of using your driveway. If you already have it, fine, use it. But suggesting Homebrew to those who simply need Java is poor advice.
People not already using Home-brew can simply download a Mac installer from a trusted source.
You have multiple sources to obtain an easy-to-use installer app to put Java on your Mac. Run the installer on your Mac just as you do for many other apps.
Here is a flowchart diagram for finding a source of Java 11, some of which also offer Java 8.
Download an installer from a vendor such as Adoptium(AdoptOpenJDK.net).
Run the installer.
JavaVirtualMachines
folder is now correct
Why doesn't Oracle's installer put it where it really goes? And how can I work around this problem?
Not a problem.
The folder /Library/Java/JavaVirtualMachines/
is the new home for JVMs on macOS.
To install a JVM, use an installer, discussed below.
To uninstall, simply use the Finder to delete a JVM from that folder. You will be prompted for system admin password to complete the removal.
Java 9 & 10 & 11
Back in 2010, Apple joined the OpenJDK project, along with Oracle, IBM, Red Hat, Azul, and other Java vendors. Each member contributes source code, testing, and feedback to the unified OpenJDK codebase.
Apple contributed most of its Mac-specific code for its JVM. Now Apple no longer releases its own Mac-specific JVM. You now have your choice of JVM supplier, with builds coming from the OpenJDK codebase.
You will find source code at: http://openjdk.java.net
New release cadence
Be aware that in 2017, Oracle, the JCP, and OpenJDK have adopted a new rapid “release train” plan for regularly-scheduled versions of Java to be delivered in a predictable manner.
Read this 2018-07 Azul Systems blog post for many details, Eliminating Java Update Confusion by Simon Ritter.
Also read Java Is Still Free.
Vendors
For a rather exhaustive list of past and present JVM implementations, see this page at Wikipedia.
Here is a discussion of a few vendors. See the flowchart above for more vendors
Oracle JDK
Oracle provides JDK and JRE installers for multiple platforms including macOS.
Over the years since acquiring Sun, Oracle has combined the best parts of the two JVM engines, HotSpot and JRocket, and merged them into the OpenJDK project used as the basis for their own branded implementations of Java.
Their new business plan, as of 2018, is to provide a Oracle-branded implementation of Java for a fee in production, and at no cost for use in development/testing/demo. Support for previous releases requires a paid support program. They have declared their intention for their branded release to be at feature-parity with the OpenJDK release. They have even donated their commercial add-ons such as Flight Recorder to the OpenJDK project.
Oracle also releases a build of OpenJDK with no support: http://jdk.java.net/
Oracle has produced a special purpose JDK, GraalVM.
Zulu & Zing by Azul
Azul Systems provides a variety of JVM products.
- Their
Zulu
line is based directly on OpenJDK, and is available at no cost with optional paid support plans.
- Their
Zing
line offers commercial JVM products enhanced with alternate technical implementations such as a specialized garbage-collector.
Both of their lines offer installers for macOS.
I am currently use Zulu for Java 10.0.1 on macOS High Sierra with IntelliJ 2018.2 and Vaadin 8. I downloaded from this page. By the way, I do not find any Java-related items installed on the Apple System Preferences app.
Adoptium
Adoptium, formerly known as AdoptOpenJDK, is a community-led effort to build binaries of the OpenJDK source. Many of the other vendors of Java implementations support this work at Adoptium.
- Your choice of either HotSpot or OpenJ9 engine.
- Builds available for macOS, Linux, and Windows, and other platforms.
OpenJ9 by Eclipse
The OpenJ9 project is an another implementation of the JVM engine, an alternative to HotSpot.
Now sponsored at the Eclipse Foundation, with technology and backing donated by IBM in 2017.
For prebuilt binaries, they refer you to the AdoptOpenJDK project mentioned above.
How to install
The installers provided by Oracle or by Azul are both utterly simple to operate. Just run the installer app on your Mac. A window appears to indicate the progress of the installation.
When completed, verify your JVM installation by:
- Visiting the
/Library/Java/JavaVirtualMachines/
folder to see an item for the new JVM.
- Running a console such as Terminal.app and type
java -version
to see the brand and version number of your JVM.
After verifying success, dismount the .dmg image in the Finder. Then trash the .dmg file you downloaded.
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/
. The previous one was where the Apple-provided Java versions went, and as Apple doesn't provide Java any more the install location has changed. – Il