Developing Java programs requires that the Java Development Kit (JDK) be installed on your machine.
The JDK (version 11) can be obtained here, for free:
https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
Mac users will likely want to use the jdk-11.0.2_osx-x64_bin.dmg link, as it is easiest to setup. Similarly, windows users will likely want to use the jdk-11.0.2_windows-x64_bin.exe link.
(If you wish to allow yourself to run java programs from the Windows command line, you will also want to update your PATH environment variable.)
Handy Tip: To find out where java was installed, open up the Terminal application and type /usr/libexec/java_home
While not required to develop Java programs, an integrated development environment (IDE) makes doing so a vastly more efficient process. Eclipse is considered to be the choice du jour of IDEs by many professional programmers.
To get started with Eclipse, you should install the "Eclipse IDE for Java Developers" which can be found here: http://www.eclipse.org/downloads/
You will discover, as you use different applications to edit your code on different machines, that tab characters in your code can often be a nuisance. To this end, it is highly recommended, once you get Eclipse installed, to do the following, which will force Eclipse to use spaces instead of tab characters when indenting: