To run a Java program you need to save the .java file in the bin directory otherwise you can't run the program without setting up the path to the bin. This is necessary because the Java Compiler, Java Application Launcher, etc. reside in the bin folder.
Several steps are there involving in setting path permanently for Java
Step 1: Click on Start Menu ->> Right Click on My Computer ->> Select Properties
Now, you'll see the System Properties window as shown in following image.
Step 2: Select Advanced tab.
Step 3: Click on Environment Variables button.
Now, another window is popped up as shown in the following image:
Step 4: Select variable Path and press Edit button.
Edit System Variable window is shown, as follows:
Step 5: Add a semicolon ( ; ) and then your path to bin folder (can be find it in the Installation Directory which is specified at the time of installation of JDK) at the end of variable value.
Press OK.
Hurray!!! You have set-up the path.