Before running Java programs on your machine you need to set two environment variables namely,
PATH − The path environment variable is used to specify the set of directories which contains executional programs.
When you try to execute a program from command line, the operating system searches for the specified program in the current directly, if available, executes it.
In case the programs are not available in the current directory, operating system verifies in the set of directories specified in the ‘PATH ’ environment variable.
CLASSPATH − The class path environment variable is used to specify the location of the classes and packages.
When we try to import classes and packages other that those that are available with Java Standard Library.
JVM verifies the current directly for them, if not available it verifies the set of directories specified in the ‘CLASSPATH’ environment variable.