Java JDK 似乎已安装,但未检测到且命令不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25320625/
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
JDK appears to install, but is not detected and commands don't work
提问by hotPocket
I just got a new computer at home. I've been trying to install JDK 8u11 on my Windows 7 64-bit machine all night. I know I downloaded the correct 64-bit version. I know I have JRE on my computer already, because java -version
returns java version "1.8.0_11"
in cmd. I can see both JRE and JDK in the Add/Remove Programs list. However, my IDE does not recognize that JDK is installed, and when I type javac
in cmd, I get 'javac' is not recognized as an internal or external command, operable program, or batch file.
This leads me to believe that JDK is not actually installed, yet I've tried reinstalling and restarting several times, and like I said before, it shows up in Add/Remove programs. I also can see the \jdk1.8.0_11 file system in \Program Files\Java, right next to the \jre8 folder. The \jdk1.8.0_11 file system looks complete, of course except for the actual application jdk-8u11.exe (or similar file). That is nowhere to be found.
我家里刚买了一台新电脑。我整晚都在尝试在我的 Windows 7 64 位机器上安装 JDK 8u11。我知道我下载了正确的 64 位版本。我知道我的电脑上已经有 JRE,因为在 cmd 中java -version
返回java version "1.8.0_11"
。我可以在“添加/删除程序”列表中看到 JRE 和 JDK。但是,我的 IDE 无法识别安装了 JDK,当我输入javac
cmd 时,我得到'javac' is not recognized as an internal or external command, operable program, or batch file.
这让我相信 JDK 并没有真正安装,但我已经尝试重新安装和重新启动几次,就像我之前说的,它出现在添加/删除程序中。我还可以在 \Program Files\Java 中看到 \jdk1.8.0_11 文件系统,就在 \jre8 文件夹旁边。\jdk1.8.0_11 文件系统看起来很完整,当然除了实际应用程序 jdk-8u11.exe(或类似文件)。那是无处可寻。
Anyone know what the problem might be?
有谁知道可能是什么问题?
NOTE: JAVA_HOME
is not an environmental variable. I have tried to manually create the environmental variable, but the following paths did not work:
C:\Program Files\Java\jdk1.8.0_11
C:\Program Files\Java\jdk1.8.0_11\bin
C:\Program Files\Java\jdk1.8.0_11\java.exe
注意:JAVA_HOME
不是环境变量。我尝试手动创建环境变量,但以下路径不起作用:
C:\Program Files\Java\jdk1.8.0_11
C:\Program Files\Java\jdk1.8.0_11\bin
C:\Program Files\ Java\jdk1.8.0_11\java.exe
采纳答案by Jaskey
Windows 7:
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Note: You may see a PATH environment variable similar to the following when editing it from the Control Panel:
%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
Windows 7的:
在桌面上,右键单击计算机图标。
从上下文菜单中选择属性。
单击高级系统设置链接。
单击环境变量。在 System Variables 部分,找到 PATH 环境变量并选择它。单击编辑。如果 PATH 环境变量不存在,请单击新建。
在 Edit System Variable(或 New System Variable)窗口中,指定 PATH 环境变量的值。单击确定。单击确定关闭所有剩余的窗口。注意:从控制面板编辑时,您可能会看到类似于以下内容的 PATH 环境变量:
%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
回答by Jaskey
First, if you have installed a 64-bit version of JDK make sure you are using same bit version of NetBeans or eclipse (64-bits) in your case.
首先,如果您安装了 64 位版本的 JDK,请确保在您的情况下使用相同位版本的 NetBeans 或 eclipse(64 位)。
then set the environment variable in (MyComputer(Properties) -> Advanced System Setting -> Environment Variables )
然后在 (MyComputer(Properties) -> Advanced System Setting -> Environment Variables 中设置环境变量)
Delete all the existing path of earlier tries of JDK as they may be overlapping and create a new one.
删除 JDK 早期尝试的所有现有路径,因为它们可能重叠并创建一个新路径。