Java is one of the oldest and most prominent languages in the world. It doesn’t matter whether you are a beginner or a professional, you would need to run some Java codes. However, we have noticed that sometimes, the terminal says that Java is not recognized as an internal or external command.
‘java’ is not recognized as an internal or external command, operable program or batch file
Java is not recognized as internal or external command
There are various instances of this issue that we get such as JAVAC’, JRE, ‘MVN’, JAR’ is not recognized as an internal or external command, operable program or batch file, ‘Java’ is not recognized as an internal or external command, operable program or batch file in Command Prompt, Minecraft, Arduino, VScode, and IntelliJ, and more. However, you will be able to resolve all those issues using the solutions mentioned below.
- Check if Java is installed on your computer
- Install Java on your computer
- Configure the environment variable
- Reinstall Java
Let us talk about them in detail.
1] Check if Java is installed on your computer
First of all, we need to make sure that Java is installed on your computer. If it’s not installed, there is no way you will be able to access it from the Command Prompt or anywhere else. To do the same, open Command Prompt and then run the following command to check which version of Java is installed on your computer. If it gives you a result, Java is installed, otherwise, move to the next solution.
2] Install Java on your computer
In case, Java is not installed on your computer, you need to go ahead and install Java. Even if it’s installed on your system, you can run the Java installation media once again and follow the instructions we are going to mention in here to install the utility correctly. To install Java on your computer, follow the steps mentioned below.
- Navigate to oracle.com to download a copy of Java SE Development Kit.
- Now, look for Windows x64 Installer and download it.
- Once it’s downloaded, you need to run the installer and follow the on-screen instructions to complete the installation process.
Hopefully, this will do the job for you.
Should the problem continue, consider installing the Java version that aligns with your existing OS. So, if you have a 64-bit Windows 10, download and install the Java version tailored for 64-bit systems. Conversely, for a 32-bit Windows Operating System, opt for the 32-bit Java program. Few users have indicated that this approach resolved their issues. Additionally, you have the option to install both Java versions, allowing you to utilize either the 32-bit or 64-bit version as per your requirements.
3] Configure the environment variables
One of the reasons why a command is not recognized as an internal or external command is that it’s not one of the environment variables. Since Java needs a compiler as well as an interpreter, we are required to add the variable manually. You can follow the steps mentioned below to do the same.
- Hit Win + S, type “View advanced system settings” and open the utility.
- Then, look for “System Properties” and click on Advanced tab.
- Then, click on Environment Variables.
- Go to the System variable section, select the PATH variable, and click on the Edit button.
- To add a variable, click on the New button.
- Now, paste the following location, which is the JDA bin location, in the given field.
C:\Program Files\Java\jdk-18.0.2\bin
- Then paste the JDA location.
C:\Program Files\Java\jdk-18.0.2
- Once done, click Ok to save the changes you just made.
Do keep in mind that, you may have a different folder, depending on the Java version you have. Once everything is done, run the problematic command and check if the issue is resolved.
4] Reinstall Java
In case, Java is not recognized, there is a high chance that the Java installed on your computer is corrupted. So, we need to uninstall Java and then install a fresh copy of the same by following the guide mentioned earlier.
Hopefully, you can resolve the issue using the solutions mentioned in this post.
Read: How to open or run a JAR file on Windows?
How do I fix Java is not recognized as an internal or external command?
As you may already know Environment variables are local to the process in which they were set. In case, Java is not configured as one of the system variables, CMD won’t be able to detect its presence and will give you the error in question. In order to resolve the issue, we are going to add Java’s path and its bin location to System Variables as that will do the trick. Follow the solutions mentioned earlier to do the same.
Read: How to set JAVA_HOME in Windows?
Why my Java version is not showing in Command Prompt?
If the Java version is not showing in the Command Prompt, it can be because of one of two reasons – Java is not installed properly on your system or its location is not added in the System Variables section. You can go through the aforementioned solutions to resolve the issue.
Also Read: WMIC is not recognized as an internal or external command.