Open the cmd window (windows Command prompt). (Click Start – type ‘cmd’ in the search box)
Type javac and hit Enter.
If your java path is not set, you will get the following error: ” ‘javac’ is not recognized as an internal or external command, operable program or batch file“.
Otherwise, you will get a long description of the command.
Anyway, most of you guys don’t have java environment variable set, that’s why you are here. To set the path just follow the simple steps.
Before proceeding, you need to have JDK installed in your system. Please click HERE to download JDK.
Step 1: Right-click on ‘My Computer’ and select properties.
Step 2: Go to ‘Advanced system settings’ from the right pane of the system window.
Step 3: The ‘System Properties’ window will open. Go to ‘Advanced‘ tab and click on ‘Environment Variables..‘.
Step 4: Now we have to add JDK home path under ‘User variables’ and JDK bin path in the section ‘System Variables‘.
Note: Your JDK installation directory may be different. If you don’t know where JDK is installed, Open cmd and copy and paste the below code and hit Enter.
for %i in (java.exe) do @echo. %~$PATH:i
Set JDK home path:
Click New –
Enter the Variable name as JAVA_HOME and Enter the Variable value as the installation path of the JDK (Java Development Kit).
Variable name : JAVA_HOME
Variable value : C:Program FilesJavajdk1.8.0_40
Set JDK bin path:
Check carefully if there is already any path variable. If there is any, you have to edit the value. Put a semi-colon (;) in front of the existing directory path variable and type the below path ( Your JDK bin directory path). The semicolon separates two directory paths.
If there isn’t any PATH variable, just add a new name and value by clicking on New.
Variable name : PATH
Variable value : C:Program FilesJavajdk1.8.0_40bin;[existing entries…]
Step 5: Click Ok after adding the Variable name and Variable value.
Step 6: Open the command prompt again, type ‘javac‘ command and hit Enter.