问题
the problem is that I upgraded to Windows 10 and now I'm installing my tools to programming and now that I installed the JDK 7 of Java, when I try to use in the cmd the command: - "javac"
The result of this is: "javac" is not recognized as an internal or external command...
But I was edited the PATH with the correct link of jdk, because when I use "java", it is ok.
Now, I tryed in the console with this command: PATH=%PATH%;"C:\Program Files\Java\jdk1.7.0_79\bin"
And when I ejecute this command, when I use "javac" it works, but now, when I open other console, it doesn´t work, or when I restart the console, this command is not recognized.
What could be the problem?
回答1:
java
is part of the JRE, not the JDK.
You need to add the JDK bin to the system PATH, in
"Control Panel" | System | Advanced | "Environment Variables"
回答2:
Her's how I configure System variable on Windows 10 :
回答3:
I am totally new to java and spent hours trying to get the problems with PATH and CLASSPATH worked out. There was one person who said to restart the command prompt after you modify the environment variables; that was it for me. While you are testing different configurations, make sure to relaunch the command prompt before testing. It seems like there are at least 2 different ways of setting this up. I went with the following:
1) In System Variables, add
JAVA_HOME = c:\program files (x86)\java\jdk1.8.0_121
2) In System Variables, add the following to existing Path...
%JAVA_HOME%\bin
That's it. No need for quotes around anything. No double forward slashes or anything else. I think it would also work if I removed the java_home variable and just listed the explicit path to bin in the PATH variable, but I'm not touching it again now that it finally works.
回答4:
After adding C:\Program Files\Java\jdk1.8.0_73\bin to the system variables I turned off my command prompt and opened another one. Then it worked.
回答5:
Maybe a bit late, but i had same problem.
Click on "Move up" button for Java path and move it at top.
It fixed problem for me
回答6:
just add C:\Program Files\Java\jdk1.7.0_80\bin as the path in environmental variables. no need to add java.exe and javac.exe to that path. IT WORKS
回答7:
I added below Path in environment variable
;%JAVA_HOME%/bin instead of %JAVA_HOME%\bin
in my case , it fix the problem
回答8:
I had the same issue on Windows 10 - the java -version
command was working but javac -version
was not. There are three things I did:
(1) I downloaded the latest jdk
(not the jre) and installed it. Then, I added the jdk/bin
path tan o environment variable. In my case, it was C:\Program Files\Java\jdk-10\bin
. I did not need to add the ;
for Windows 10.
(2) Move this path to the top of all the other paths.
(3) Delete any other Java paths that might exist.
Test the java -version
and javac -version
commands again. Voila!
回答9:
For some reason it worked for me to add quotation marks to the path folder on windows 10. not C:\Program Files\Java\jdk 1.8.0_111\bin, but "C:\Program Files\Java\jdk 1.8.0_111\bin".
回答10:
now i got it finally! make sure that there are no spaces before and after the path and put the semi-colon on both sides without spaces
回答11:
The PATH is for current user, instead you can add a CLASSPATH and below link would help you more PATH and CLASSPATH
回答12:
I added below Path in environment variable
C:\Program Files\Java\jdk1.8.0_91\bin
and then compiled the program but got the error then I restarted the system and again compiled the program
This time it worked :)
回答13:
Add java path to environment variables and move it to the top of all the paths available there. It worked for me.
回答14:
To be sure about your path, you can use double quotes " to locate the path or if you are in Windows, you can browse to path to select "C:\Program Files\Java\jdk1.8.0_121\bin"
folder.
回答15:
in the search window type 'environment variables' this should give you a link to editing the variables. On the variables editing page there is an upper section and a lower section in the lower section add NEW,type path C:\Program Files\Java\jdk-10\bin this worked great for me and it finds the compiler all the time.
回答16:
Kind of beating a dead horse now but, I want to clarify one thing that may not be quite so obvious. Yes indeed you need to edit the PATH environment variable as already stated many times. The key for me was to edit the PATH under SYSTEM variables. I had inadvertently edited the PATH under USER variables. Why did this matter? On my machine I have to log in as an Administrator to edit environment variables. So editing the User variables was not helping because I run the command prompt under my login (non-admin) account. Grrr!
Also, I found that closing the command prompt window, and re-opening it after the PATH variable update was required. Changing the order of the values, adding semi-colons, etc. didn't make a difference for me.
Cheers
回答17:
If you have set all PATH variables correctly after installation, just restart it.
I had the same problem, I had also installed new Windows7 OS then I upgraded it to Win 10. Then i started setup necessary tools like IntelliJ, Java jdk,jre, eclipse so on. In cmd, java -version worked but javac compiler got unrecognized. I checked and all good, the files in the folders, path are correct and so on.
I restarted and checked it again in cmd ,it worked.
回答18:
what I did is:
I typed ;
accidentally in front in the path variable and then hit OK
, after this if I again edit it was nowhere going to the same page as earlier, it opened a new page as defined for user variables and then I was able to remove double quotes
in front of the PATH VARIABLE.
Everything worked fine then. :)
Did it just now.
回答19:
Add
PATH = C:\Program Files\Java\jdk1.8.0_66\bin
in Advanced system setting
. Then Choose Environment Variable.
回答20:
for windows 10 Users Use Java path( JDK Bin location) AS "C:\Program Files\Java\jdk-9.0.1\bin" it will work.
回答21:
Points to remember, do as the image shows. Move the highlighted bar up using move up button, this will help.
来源:https://stackoverflow.com/questions/31925437/javac-doesnt-work-correctly-on-windows-10