After installing the JDK (Java Development Kit), open the properties of your computer,
(
+ Pause Break or Initiate → Control Panel → System) and click on Advanced System Settings.

Click on Environment variables...

Click on New and create the following two variables:
CLASSPATH = .;%JAVA_HOME%
JAVAHOME = Caminho do Java instalado
After creating variables, edit the variable Path and put a semicolon (;) at the end of the value and add the folder path bin where Java was previously installed:

After configuring these steps, restart your computer to apply the settings and you can compile your code .java simply typing javac and the file name .java in the prompt of Windows. And running informing java followed by the previously compiled class.
To leave the response documented...
Do you have the JAVA_HOME variable set in the environment? Are you running the commands in the Java directory (Java"version of jdk" bin)? And you are using the commands by cmd?
– Gustavo Cinque
Yes, the problem was that it did not compile, so I’m trying the eclipse run and it worked. I installed java 8.
– user12096