- 1 year ago
'java' is not recognized as an internal or external command, operable program or batch file
The error message "'java' is not recognized as an internal or external command, operable program or batch file" indicates that the Java executable (java
) is not found or not properly set up in the system's PATH environment variable. Here are a few steps you can take to resolve this issue:
Verify Java Installation:
- Make sure that Java is installed on your system. You can download the latest version of Java Development Kit (JDK) from the official Oracle website (https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) and install it following the provided instructions.
Set the JAVA_HOME Variable:
- After installing Java, set the
JAVA_HOME
environment variable to the Java installation directory:- Open the Start menu and search for "Environment Variables".
- Select "Edit the system environment variables".
- In the System Properties window, click on the "Environment Variables" button.
- Under the "System variables" section, click on "New" to add a new variable.
- Set the variable name to
JAVA_HOME
and the variable value to the Java installation directory (e.g.,C:\Program Files\Java\jdk-11.0.12
). - Click "OK" to save the changes.
- After installing Java, set the
Update the PATH Variable:
- Edit the PATH environment variable to include the
bin
directory of the Java installation:- In the same "Environment Variables" window, select the "Path" variable under the "System variables" section and click on "Edit".
- Add the following value at the end of the list:perl
%JAVA_HOME%\bin
- Click "OK" to save the changes.
- Edit the PATH environment variable to include the
Restart the Command Prompt:
- Close and reopen any open Command Prompt windows to ensure that the updated environment variables take effect.
After following these steps, try running the java
command again in a new Command Prompt window. It should now recognize the java
command and execute Java programs without displaying the error message.
If the issue persists, double-check the Java installation and ensure that you've correctly set the JAVA_HOME
and PATH environment variables. You may also need to check your system's configuration and ensure that there are no conflicting Java installations or outdated environment variables causing the problem.