Reputation: 11
I'm getting an error when typing javac
in command prompt.
C:\Users\HP>javac
javac is not recognized as an internal or external command, operable program or batch file.
C:\Users\HP>set path
path=C:\Program Files\Java\jdk-10\bin;C:\Program Files\Java\jre-10\bin\javaw.exe;C:\Program Files\Java\jdk-10\bin;C:\Program Files\Java\jre-10\bin;
PATHEXT=C:\Program Files (x86)\Documents;
I have already set Path
in both system and user scope environment varible?
Upvotes: 1
Views: 5036
Reputation: 4937
On Windows 10, the problem of 'javac is not recognized ...' can be fixed in these 4 steps:
Step 1: Install JDK to specific path (Example: C:\jdk-15)
Step 2: Setup JAVA_HOME environment variable to the installation folder
Windows --> Advanced settings --> Environment variables --> System Variable
--> Add new variable
JAVA_HOME = C:\jdk-15
Step 3: Prefix JAVA_HOME\bin to PATH variable of Windows
Windows --> Advanced settings --> Environment variables --> System Variables
--> Update PATH variable
PATH = JAVA_HOME\bin;..... old value of PATH variable ....
Step 4: Try the javac and java commands in new command window
Note: Already opened command windows will not take the new values of JAVA_HOME or PATH. The test needs to be done in new window opened after the environment variables are changed and saved.
C:\Users\user1> javac -version
C:\Users\user1> java -version
Upvotes: 0
Reputation: 1985
Try out the following solutions.
Close your current cmd
and Open a new cmd.exe
Restart the computer
NOTE: If cmd
is open when you set the environment variables, then, that property will not be available until unless you open new cmd
.
Upvotes: 0
Reputation: 30103
The PATH
variable looks corrupted. Moreover, the PATHEXT
variable is totally confused. Their default value in Windows 7/10/2008 (assuming the system drive is C:
) should be as follows:
PATH C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths}
PATHEXT .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .MSC
Check output from SET PATH
in a freshly open cmd
window. If path
and pathext
look as above then use (modify directory names to match current Java version):
set "JAVA_HOME=C:\Program Files\Java\jre-9.0.4"
set "PATH=%JAVA_HOME%\bin;%PATH%"
Above setting is temporary (would last only for current cmd
session). For persistent solution, there are more tutorials on the net e.g. How To Set Java Path & Java Home Variables (Windows, MacOS, Ubuntu).
Upvotes: 0
Reputation: 833
You may set 2 system variable from console:
set JAVA_HOME="c:\Program Files\Java\jdk1.8.0_144"
set PATH=%JAVA_HOME%\bin;%PATH%
then your command "javac" will be found.
Upvotes: 4