简体   繁体   中英

"Javac" doesn't work correctly on Windows 10

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 tried in the console with this command: PATH=%PATH%;"C:\\Program Files\\Java\\jdk1.7.0_79\\bin"

And when I executed the command "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?

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"

Her's how I configure System variable on Windows 10 :

在此处输入图片说明

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.

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.

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

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

I added below Path in environment variable

;%JAVA_HOME%/bin instead of %JAVA_HOME%\\bin

in my case , it fix the problem

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!

出于某种原因,我在 Windows 10 上的路径文件夹中添加引号对我有用。不是 C:\\Program Files\\Java\\jdk 1.8.0_111\\bin,而是“C:\\Program Files\\Java\\jdk 1.8.0_111\\斌”。

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

PATH 适用于当前用户,您可以添加一个 CLASSPATH,下面的链接将帮助您了解更多PATH 和 CLASSPATH

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 :)

Add java path to environment variables and move it to the top of all the paths available there. It worked for me.

要确定您的路径,您可以使用双引号"来定位路径,或者如果您在 Windows 中,您可以浏览到路径以选择"C:\\Program Files\\Java\\jdk1.8.0_121\\bin"文件夹。

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.

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

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.

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.

Add

PATH = C:\Program Files\Java\jdk1.8.0_66\bin 

in A dvanced system setting . Then Choose Environment Variable.

对于 Windows 10 用户使用 Java 路径(JDK Bin 位置)作为“C:\\Program Files\\Java\\jdk-9.0.1\\bin”它会起作用。

Points to remember, do as the image shows. Move the highlighted bar up using move up button, this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM