If Java is on your Mac, you’ll see a message saying something like “Java (TM) Runtime Environment” in this case version 1.6 (or Java 6 as it is commonly known). If you’re not sure whether Java is installed on your Mac, simply search for Terminal in Spotlight and type: java -version at the command prompt.
If you’ve never installed Java on Mac, then you can simply download and install the latest version of Java from Oracle which is known as Java 8 but rather confusingly officially called Java 1.8 by Oracle.
It’s because an application you have installed or a website you’re trying to access requires Java to launch or work properly. To use the “java” command line tool you need to install a Java SDK