- First thing we need to compile java programs is to have JDK(Java development Kit) installed on your computer. If you are not sure whether your computer has it installed or not, you can verify from appwiz.cpl.(More details here – How do I check if Java is installed on my system) Note that having JRE is not enough to develop java applications. JRE only helps to run already built applications, JDK(which Javac is bundled into) is also needed if you are developing software in java.
- If java is installed, then you need to check if PATH environment variable points to the java executables directory.
- Open command prompt
- Run ‘set path’. This will print the current value of path environment variable. You can see the list of all the directories added. Check if Java sdk path is added or not. If it’s added you should be able to see something like below.
Path=C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Quarantine\;C:\Program Files\Perforce;C:\Program Files\Microsoft Network Monitor 3\;c:\Program Files\Java\jdk1.7.0_17\bin
- If you don’t find JDK path you can add now. Please note that the path you need to add on your system would vary based on the SDK version you installed and also the location of the installation. Check the folder “C:\Program Files\java” and “c:\Program Files (x86)\java” to find the exact path.
- If you already have PATH set with the java location, check one more time if you have added path till the
binfolder. So adding
c:\Program Files\Java\jdk1.7.0_17is not correct. You need to add
- You can modify PATH variable from command prompt or from GUI. For command line steps, please see – Set path from windows command prompt
- To modify PATH using GUI you can follow the steps below.
How to set JDK path
- Open System properties (Run sysdm.cpl)
- Go to Advanced tab
- Click ‘Environment variables’
- Under ‘System Variables’ scroll down to find PATH. Edit the entry and add JDK path.
- Click OK and close the windows.
Now open new command prompt and run ‘set path’, you can see that JDK path is added. Note that if you run the command from a window which was opened before you modified the PATH variable, it would not print updated path. Even for compiling java programs, you need to open a new command window after setting PATH.
Javac not recognized as internal or external command
Javac is the utility for compiling java applications. When compiling a java program from command line, the most common issue people get into is “Javac is not recognized as internal or external command’. Let’s see how we can fix this issue.