找不到Java命令 [英] Java command not found
问题描述
我正在尝试让java命令在我的计算机上运行。每当我尝试使用它时,我都会收到错误'java'未被识别为内部或......
I'm trying to get the java command to work on my computer. Whenever I try to use it, I get the error "'java' is not recognized as an internal or..."
我做了什么
到目前为止,我已经通过我的系统环境变量跟踪了这个问题,该变量有一个链接到C:\ProgramData \ Oracle \ Java \ _javapath或javapath的变量PATH简而言之。
What I've done
So far I've traced the issue through my system environment variables, which has a variable PATH that links to "C:\ProgramData\Oracle\Java\javapath" or javapath for short.
javapath文件夹中有3个文件,如果点击它们,弹出窗口会显示:
There are 3 files in the javapath folder, and if you click on them a popup says:
但是当我检查快捷方式的属性并单击打开文件夹位置时,它会将我发送给正确的地方(??这是什么)。
But when I examine the properties of the shortcut and click "open folder location" it sends me to the right place (?? what is this).
以防万一,我试图重新创建快捷方式;我称它为java2,它现在可以正常工作(打开命令框一瞬间关闭),当我点击它时。但是,在命令提示符下使用java2 -version行返回'java2'进行测试不会被识别为内部或外部......
Just in case, I tried to recreate the shortcut; I called it java2 and it now works (opens a command box for a split second and closes) when I click on it. However, testing it in command prompt with the line "java2 -version" returns "'java2' is not recognized as an internal or external..."
详细信息
我刚刚安装了java 8,并且我已经验证它已正确安装
Details
I just installed java 8, and I've verified that it was installed correctly
我正在运行64位Windows 7操作系统
I'm running a 64 bit windows 7 OS
推荐答案
您是否检查过Windows的环境变量?安装JDK / JRE时,该目录应该已添加到PATH变量中。添加的目录需要包含java.exe可执行文件。如果您使用默认设置安装它,它应该位于 C:\Program Files \ Java 之类的东西。一旦找到该目录,就会在其中找到bin目录。
Have you checked your environment variables for Windows? When you installed the JDK/JRE the directory should have been added to the PATH variable. The directory added needs to contain the java.exe executable. It should be located in C:\Program Files\Java or something like that if you installed it using the default settings. Once you find that directory find the bin directory inside it.
为了检查:
- 右键单击我的电脑,然后点击属性
- 在左侧点击高级系统设置
- 点击高级选项卡然后点击环境变量在底部
- 找到PATH变量,然后点击编辑。确认JDK / bin目录的位置在那里,如果不存在则添加它。
- Right click My Computer and hit Properties
- On the left side hit Advanced System Settings
- Hit the Advanced tab and then Environment Variables down at the bottom
- Find the PATH variable and then hit edit. Confirm that the location of the JDK /bin directory is there, if it is not then add it.
此外,如果JAVA_HOME变量尚未设置,这可能是一个好主意。
Also, if the JAVA_HOME variable isn't already set, this may be a good idea.
这篇关于找不到Java命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!