You need either a Java Runtime Environment or a Java Development Kit installed.
Depending on your platform, you have to make sure the JAVA_HOME environment variable points to the directory where the version was installed (in some platforms the installer takes care of this for you), and that you have $JAVA_HOME/bin in your PATH.
Windows Configuration of JAVA_HOME
Windows 10 and Windows 8
In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.