You may already have Java installed on your machine. You can check by opening a terminal window and running the java -version command, as shown next (macOS):
You can see that this machine is running Java version 1.8.0, or more commonly, JDK 8 (the 1. prefix is unspoken). You should have the current version. If you do not have Java or need to upgrade, browse to the Java SE Downloads web page, http://www.oracle.com/technetwork/java/javase/downloads/index.html, and get it.
Look for the Java Platform (JDK) button icon, as shown in the following image; it will take you to the Downloads page:
Choose the package ...