Set-java-environment-variable-path-in-windowsFirst, check whether the path is set or not.

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 on your system. Please click HERE to download JDK.

Set Java environment variable

At first, you need to right-click on ‘My Computer’ and select properties.

Now go to ‘Advanced system settings’ from the right pane of the system window.

Set java environment variable path in windows

The ‘System Properties’ window will open. Go to ‘Advanced‘ tab and click on ‘Environment Variables..‘.

Set-java-environment-variable-path-in-windows-(1)

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.

Set java environment variable path in windows

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 java environment variable path in windows java-environment-variable

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…]

Set java environment variable path in windows

Set java environment variable path in windows (2)

Now that you have added Variable name and Variable value, click OK.

After adding the name and value you need to open the command prompt again, type ‘javac‘ command and hit Enter.

java-environment-variable That’s all you need to run Java code from cmd.
Set Java environment variable – ‘javac’ is not recognized as an internal or external command
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *