“Javac”在 Windows 10 上无法正常工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31925437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 11:47:19  来源:igfitidea点击:

"Javac" doesn't work correctly on Windows 10

javawindowsjava-7javacwindows-10

提问by Sad?k

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"

问题是我升级到了 Windows 10,现在我正在安装我的编程工具,现在我安装了 Java 的 JDK 7,当我尝试在 cmd 中使用命令时:-“javac”

The result of this is: "javac" is not recognized as an internal or external command...

这样做的结果是:“javac”未被识别为内部或外部命令...

But I was edited the PATH with the correct link of jdk, because when I use "java", it is ok.

但是我用jdk的正确链接编辑了PATH,因为当我使用“java”时,它是可以的。

Now, I tryed in the console with this command: PATH=%PATH%;"C:\Program Files\Java\jdk1.7.0_79\bin"

现在,我在控制台中尝试使用以下命令: 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.

当我弹出这个命令时,当我使用“javac”时它可以工作,但是现在,当我打开其他控制台时,它不起作用,或者当我重新启动控制台时,无法识别此命令。

What could be the problem?

可能是什么问题呢?

采纳答案by SLaks

javais part of the JRE, not the JDK.

java是 JRE 的一部分,而不是 JDK。

You need to add the JDK bin to the system PATH, in

您需要将 JDK bin 添加到系统 PATH,在

"Control Panel" | System | Advanced | "Environment Variables"

“控制面板” | 系统 | 高级 | “环境变量”

回答by ihappyk

The PATH is for current user, instead you can add a CLASSPATH and below link would help you morePATH and CLASSPATH

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

回答by A_Anonymous

Add

添加

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

in Advanced system setting. Then Choose Environment Variable.

在 A dvanced system setting。然后选择Environment Variable.

回答by Crispy

Maybe a bit late, but i had same problem.

也许有点晚了,但我有同样的问题。

Click on "Move up" button for Java path and move it at top.

单击 Java 路径的“向上移动”按钮并将其移动到顶部。

It fixed problem for me

它为我解决了问题

回答by Sreeni

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

只需添加 C:\Program Files\Java\jdk1.7.0_80\bin 作为环境变量中的路径。无需将 java.exe 和 javac.exe 添加到该路径。有用

回答by Mahesh Sonavane

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

她是我在 Windows 10 上配置系统变量的方式:

enter image description here

在此处输入图片说明

回答by Ram kaatiya

I added below Path in environment variable

我在环境变量中的路径下面添加了

C:\Program Files\Java\jdk1.8.0_91\bin

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

这次成功了:)

回答by troh

I added below Path in environment variable

我在环境变量中的路径下面添加了

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

;%JAVA_HOME%/bin 而不是 %JAVA_HOME%\bin

in my case , it fix the problem

就我而言,它解决了问题

回答by M?ciwój Ogórkowski

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".

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

回答by V.P.

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.

将 C:\Program Files\Java\jdk1.8.0_73\bin 添加到系统变量后,我关闭了命令提示符并打开了另一个。然后它起作用了。