After you have installed java open your command prompt or simply click at start button and then click run.
A small window will be opened. Write cmd in the text/search box and press run button.
Once you have opened command prompt open the drive/partition in which you have saved your program.
For example i have save my program in "local disk d/my progs". Write "d:" in command prompt and press enter.
After this write the folder name (as in above paragraph d/my progs) and press enter. I will write it as "my progs" and then enter. Now, write your program name and press enter. Just like this:
javac salary.java
there "javac" is the command to compile your program and "salary.java" shows that the programs name is salary and it is a java file.
Finally your program is compiled and ready to execute. When your program will be compiled successfully a class file of the program will be created in the same folder as in your program. To execute your program just write the following command
java salary
and your program will be executed.
Note:
"salary" is the program name. You should write the name of your program.