One of the most basic steps to work with java is to set your path variable so that you can compile and run your java related commands from the location where your java programs reside and not from the bin directory of JDK.
You might get this error in case the path is not set in environment variables:
‘javac’ is not recognized as an internal or external command, operable program or batch file
![Error when java path is not set in path variable](https://testingtools.co/wp-content/uploads/2016/05/Error-when-java-is-not-set-in-path-variable.png)
Follow the below step by step instructions to set the java path in windows environment variable:
- Make a note of the bin directory path of java and keep it available.
- Right click on Computer and select Properties context menu.
![My Computer > Properties](https://testingtools.co/wp-content/uploads/2016/05/My-Computer-Properties.png)
- Click on advanced System Settings.
![Navigate to advanced System Settings](https://testingtools.co/wp-content/uploads/2016/05/Navigate-to-advanced-System-Settings.png)
- Click on Environment Variables button of System Properties Window under “Advanced” tab.
![System Properties > Advanced > Environment Variables](https://testingtools.co/wp-content/uploads/2016/05/System-Properties.png)
- Now in the “Environment Variables” window under “System Variables” section, scroll to see the variable by name path, select and click on edit.
![Edit Path Environment Variable](https://testingtools.co/wp-content/uploads/2016/05/Edit-Path-Variable.png)
- You will now be presented with a small window with variable name and value, go to the end of the variable, make sure you add one semi colon at the end of the current value in case it is not there and then paste your bin directory path, for example: as per my machine it is “C:\Program Files\Java\jdk1.8.0_91\bin” without double quotes, you need to form this based on the location java is installed in your machine and click on Ok button.
![Set Java Bin directory in Path variable](https://testingtools.co/wp-content/uploads/2016/05/Set-Bin-directory.png)
- Click on Ok buttons to close the parent windows as well.
- You are done with setting the path variable successfully, in order to verify if everything is fine, open a new command prompt, change directory to “c:\” drive using the command “cd \” without double quotes.
- Now try the javac command and you shall see the following message, which means, the variable is set properly and from now you can create your java programs in your desired location.
![Javac working from different folder locations](https://testingtools.co/wp-content/uploads/2016/05/Successfully-Set-Java-Path.png)
Finally you are all set to compile and run your java programs from your desired folder location.
Share your queries in form of comments, we would be more than happy to help