Troubleshooting "javac is not recognized" Error in Windows
Problem:
While trying to compile Java programs, you encounter the error: "'javac' is not recognized as an internal or external command, operable program or batch file."
Solution:
1. Verify Java Installation:
Ensure you have installed the Java Development Kit (JDK), not just the Java Runtime Environment (JRE). Check your installed programs list for "Development Kit."
2. Locate the Java Path:
- Exe installer: Navigate to C:Program Files (x86)Java and find the latest JDK version folder named "jdkX.XX.X.XX". Enter the bin directory and copy its path.
- Zip file: Extract the JDK to a suitable location, find the bin folder, and copy its path.
3. Edit Environment Variables:
- Use the search bar to find "environment variable" settings.
- Look for the PATH variable and inspect its value for any Java paths. Remove duplicate or outdated Java paths, as well as "C:ProgramDataOracleJavajavapath."
4. Add Java Path to PATH:
- Paste the correct Java path at the end of the PATH variable and separate it with a semicolon.
- For pre-Windows 10 users, ensure correct semicolon placement.
5. Set JAVA_HOME:
- Create or edit the JAVA_HOME environment variable as a system variable.
- Set its value to the Java directory path without the bin directory, e.g., C:Program Files (x86)JavajdkX.XX.X.XX
6. Close and Re-open Command Prompt:
- Close and re-open Command Prompt to load the updated environment variables.
7. Additional Tips:
- Remove paths related to uninstalled software from PATH.
- Consider adjusting the order of paths if necessary.
- Remember to set JAVA_HOME after upgrading Java.
The above is the detailed content of Why Doesn't My Windows Command Prompt Recognize 'javac'?. For more information, please follow other related articles on the PHP Chinese website!