You will need a Java development environment (JDK) to write Java programs. You can download the Sun Microsystems JDK from the Java website.
Installing the JDK – Java Development Environment
Run the Setup application to put the JDK or the sample files on Windows. The package installs in C:\Program Files\Java\jdk1.8.0_112, but you can choose a different location. You will be able to choose whether or not to install the JDK, the example files, and other supplementary files. You will install those items if you select the desired options.
On the Macintosh, double-click the installation software to install the JDK or the sample files. By default, the package will install in the Java folder on your hard drive, but you have the option to place it elsewhere.
Set JAVA_HOME:
There are two ways to set the Java path
Temporary Way of Setting Java Path
javac
If you don’t have Java installed, the following message will appear:
Javac is not a command that can be run from the command line, an internal or external program, or a batch file.
javac
You can check that the path is set if no error has been raised.
Permanent of Setting Java Path
Java Development Environment
On the Advanced tab, select Environment Variables and then edit
Checking Java Version (java -version)
To check the Java version, you must add the path to environment variables, which you can find in the Control Panel. Open the JDK installation folder and add the path up to the /bin directory in the environment variables. Then, add the path variable to System Variables, which resides in Environment Variables.
java -version
This command will display the current version of Java that is installed on your machine.
To get your JDK location in Windows, run this at a command prompt:
where java