“Java”不被视为内部或外部命令

时间:2021-05-14 23:10:31

When trying to check the current version of Java in which I am running, I receive the error "'java' is not recognized as an internal or external command, operable program or batch file.".

当尝试检查正在运行的Java的当前版本时,我收到错误“' Java '不被识别为内部或外部命令、可操作程序或批处理文件”。

I am running Windows 7 OS and have downloaded the latest JDK and feel I may have accidentally deleted the java from machine as before I was able to check the Java version using the command "java -version".

我正在运行Windows 7操作系统,并下载了最新的JDK,感觉自己可能在使用“java -version”命令检查java版本之前不小心从机器上删除了java。

What software must I download to get Java working on my machine again?

我需要下载什么软件才能让Java在我的机器上运行?

EDIT:

编辑:

I have managed to get Java running from my cmd again after ensuring all environment variables pointed to the current java sdk. Thank you for all answers to my question, Karen

在确保所有环境变量都指向当前的Java sdk之后,我成功地让Java从cmd运行。谢谢你回答我的问题,凯伦

12 个解决方案

#1


115  

You need to configure your environment variables, JAVA_HOME and PATH.

您需要配置环境变量、JAVA_HOME和PATH。

JAVA_HOME must contain the path to java, and you should add %JAVA_HOME%\bin to PATH

JAVA_HOME必须包含到java的路径,您应该向路径添加%JAVA_HOME%\bin

Alternatively, you can simply add to your PATH the whole path to the bin folder, without the JAVA_HOME variable, however, this makes a little more annoying when you need to have more than one java version on your machine (that way you only need to change JAVA_HOME and don't even bother with PATH)

或者,您可以添加到您的路径bin文件夹,整个路径没有JAVA_HOME变量,然而,这使得更烦人当您需要在您的计算机上有多个java版本(这样你只需要改变JAVA_HOME和甚至不能解决路径)

#2


69  

For Windows 7:

Windows 7:

  1. Right click on My Computer
  2. 右击我的电脑
  3. Select Properties
  4. 选择属性
  5. Select Advanced System Settings
  6. 选择高级系统设置
  7. Select Advanced tab
  8. 选择高级选项卡
  9. Select Environment Variables
  10. 选择环境变量
  11. Select Path under System Variables
  12. 在系统变量下选择路径
  13. Click on Edit button
  14. 点击编辑按钮
  15. In Variable value editor paste this at the start of the line

    在变量值编辑器中,在行开头粘贴这个

    C:\Program Files\Java\jdk1.7.0_72\bin;
    
  16. Click Ok then Ok again

    单击Ok然后再次单击Ok

  17. Restart command prompt otherwise it won't see the change to the path variable
  18. 重新启动命令提示符,否则它将看不到对path变量的更改
  19. Type java -version in command prompt.
  20. 在命令提示符中输入java -version。


Notes on Step 8:
1. The version of java in this may be different from the one used here -- this is only an example.
2. There will probably be other values in the path variable. It is really important that you don't delete what's already there. That's why the instructions say to paste the given value at the start of the line -- this means that you don't remove the existing value, you just put java before it. This also fixes any problems you'd be getting if an other version of java is also on the path.

Notes on Step 6:
1. This sets the path for the computer, not for the individual user. It may be that you're working on a computer which other developers also use, in which case you'd rather set the user variables, rather than the system variables

步骤6:1。这将为计算机设置路径,而不是为单个用户设置路径。这可能是因为您正在使用其他开发人员也在使用的计算机,在这种情况下,您宁愿设置用户变量,而不是系统变量

#3


38  

It sounds like you haven't added the right directory to your path.

似乎您还没有将正确的目录添加到路径中。

First find out which directory you've installed Java in. For example, on my box it's in C:\Program Files\java\jdk1.7.0_111. Once you've found it, try running it directly. For example:

首先找出您在哪个目录中安装了Java。例如,在我的箱子在C:\Program Files\java\ jdk1.7.0_111。一旦你找到了它,试着直接运行它。例如:

c:\> "c:\Program Files\java\jdk1.7.0_11\bin\java" -version

Once you've definitely got the right version, add the bin directory to your PATH environment variable.

一旦确定了正确的版本,将bin目录添加到PATH环境变量中。

Note that you don't need a JAVA_HOME environment variable, and haven't for some time. Some tools may use it - and if you're using one of those, then sure, set it - but if you're just using (say) Eclipse and the command-line java/javac tools, you're fine without it.

注意,您不需要JAVA_HOME环境变量,而且已经有一段时间不需要了。有些工具可能会使用它——如果您正在使用其中的一个工具,那么当然要设置它——但是如果您只是使用(比如)Eclipse和命令行java/javac工具,那么没有它就没有问题。


1 Yes, this has reminded me that I need to update...

是的,这提醒我我需要更新……

#4


16  

“Java”不被视为内部或外部命令

Step 1. Open your windows property i.e. (windows+Pause Break) then goto Advance System setting . 2. select Advance Tab---> Env.variable --> add variable as shown in figure. Now Open your command prompt and check for: 1. java 2. Javac are executing successfully. If still error is there i.e. "java' is not recognized as an internal or external command" then check whether you have installed jdk twice. If yes then uninstall and follow above step.

步骤1。打开你的windows属性,也就是(windows+Pause Break),然后继续升级系统设置。2。选择预先选项卡- - - > Env。变量——>添加变量,如图所示。现在打开命令提示符并检查:1。java 2。Javac是成功执行。如果仍然存在错误,也就是。“java”不被识别为内部或外部命令”,然后检查您是否安装了两次jdk。如果是,则卸载并执行上述步骤。

#5


4  

For me its start working after putting ,: in the starting of the system variable path :--


“Java”不被视为内部或外部命令

对于我来说,它在put之后开始工作,在系统变量路径的开始:—

“Java”不被视为内部或外部命令


#6


3  

This problem is on Windows 8. First copy your Path of java jdk - e.g. C:\Program Files\Java\jdk1.7.0_51\bin.

这个问题出现在Windows 8上。首先复制你的java jdk的道路——例如C:\Program Files\Java\ jdk1.7.0_51 \ bin。

  1. Right on the My Computer Icon on the Desktop and Click Properties.

    在桌面上的My Computer图标上单击Properties。

  2. Select 'Advanced System Settings' in the left pane.

    在左边窗格中选择“高级系统设置”。

  3. Under 'Advanced' tab, select 'Environment Variables' at the bottom.

    在“高级”选项卡下,在底部选择“环境变量”。

  4. In System Variables, select 'Path' Variable and edit it.

    在系统变量中,选择“Path”变量并对其进行编辑。

Paste the path and add a ';' at the end - e.g. C:\Program Files\Java\jdk1.7.0_51\bin;

粘贴的路径,并添加一个“;”结束时——例如C:\Program Files\Java\ jdk1.7.0_51 \ bin。

#7


1  

I had the same problem. Just Install the exact bit of java as of your computer. If your PC is 64 bit then install 64 bit java. If it is 32 bit then vice versa :)

我也有同样的问题。只需安装您的计算机的确切的java字节。如果你的电脑是64位,然后安装64位java。如果是32位,反之亦然:)

#8


0  

if you have cygwin installed in the Windows Box, or using UNIX Shell then

如果您已经在Windows Box中安装了cygwin,或者使用了UNIX Shell

Issue bash#which java

This will tell you whether java is in your classpath or NOT.

这将告诉您java是否在类路径中。

#9


0  

In my case, PATH was properly SET but PATHEXT has been cleared by me by mistake with .exe extension. That why window can't find java or anything .exe application from command prompt. Hope it can help someone.

在我的例子中,路径被正确设置,但是我错误地用.exe扩展清除了PATHEXT。这就是为什么窗口不能从命令提示符找到java或任何。exe应用程序。希望它能帮助某人。

#10


0  

I had this problem too.finally i solve it.you should enter a space between 'java' and '-'. i.e you should enter 'java -version' in cmd.

我也有这个问题。最后我解决它。您应该在“java”和“-”之间输入空格。我。你应该在cmd中输入“java -version”。

#11


0  

I did all of it, and it didn't work for me, but , finally, I found where I was mistaking all that time :). I didn't type "space" between java and -version. It should be typed like this: java -version. With space between "java" and "-version". Now it works for me.

我做了所有的事情,但这对我来说并不管用,但最终,我找到了我一直在犯错的地方:我没有在java和-version之间输入“空格”。它的类型应该是:java -version。在“java”和“-version”之间有空格。现在它对我很有效。

#12


-1  

My solution was to put same value (path to JDK bin folder) in JAVA_HOME and Path

我的解决方案是将相同的值(到JDK bin文件夹的路径)放在JAVA_HOME和path中

“Java”不被视为内部或外部命令“Java”不被视为内部或外部命令

#1


115  

You need to configure your environment variables, JAVA_HOME and PATH.

您需要配置环境变量、JAVA_HOME和PATH。

JAVA_HOME must contain the path to java, and you should add %JAVA_HOME%\bin to PATH

JAVA_HOME必须包含到java的路径,您应该向路径添加%JAVA_HOME%\bin

Alternatively, you can simply add to your PATH the whole path to the bin folder, without the JAVA_HOME variable, however, this makes a little more annoying when you need to have more than one java version on your machine (that way you only need to change JAVA_HOME and don't even bother with PATH)

或者,您可以添加到您的路径bin文件夹,整个路径没有JAVA_HOME变量,然而,这使得更烦人当您需要在您的计算机上有多个java版本(这样你只需要改变JAVA_HOME和甚至不能解决路径)

#2


69  

For Windows 7:

Windows 7:

  1. Right click on My Computer
  2. 右击我的电脑
  3. Select Properties
  4. 选择属性
  5. Select Advanced System Settings
  6. 选择高级系统设置
  7. Select Advanced tab
  8. 选择高级选项卡
  9. Select Environment Variables
  10. 选择环境变量
  11. Select Path under System Variables
  12. 在系统变量下选择路径
  13. Click on Edit button
  14. 点击编辑按钮
  15. In Variable value editor paste this at the start of the line

    在变量值编辑器中,在行开头粘贴这个

    C:\Program Files\Java\jdk1.7.0_72\bin;
    
  16. Click Ok then Ok again

    单击Ok然后再次单击Ok

  17. Restart command prompt otherwise it won't see the change to the path variable
  18. 重新启动命令提示符,否则它将看不到对path变量的更改
  19. Type java -version in command prompt.
  20. 在命令提示符中输入java -version。


Notes on Step 8:
1. The version of java in this may be different from the one used here -- this is only an example.
2. There will probably be other values in the path variable. It is really important that you don't delete what's already there. That's why the instructions say to paste the given value at the start of the line -- this means that you don't remove the existing value, you just put java before it. This also fixes any problems you'd be getting if an other version of java is also on the path.

Notes on Step 6:
1. This sets the path for the computer, not for the individual user. It may be that you're working on a computer which other developers also use, in which case you'd rather set the user variables, rather than the system variables

步骤6:1。这将为计算机设置路径,而不是为单个用户设置路径。这可能是因为您正在使用其他开发人员也在使用的计算机,在这种情况下,您宁愿设置用户变量,而不是系统变量

#3


38  

It sounds like you haven't added the right directory to your path.

似乎您还没有将正确的目录添加到路径中。

First find out which directory you've installed Java in. For example, on my box it's in C:\Program Files\java\jdk1.7.0_111. Once you've found it, try running it directly. For example:

首先找出您在哪个目录中安装了Java。例如,在我的箱子在C:\Program Files\java\ jdk1.7.0_111。一旦你找到了它,试着直接运行它。例如:

c:\> "c:\Program Files\java\jdk1.7.0_11\bin\java" -version

Once you've definitely got the right version, add the bin directory to your PATH environment variable.

一旦确定了正确的版本,将bin目录添加到PATH环境变量中。

Note that you don't need a JAVA_HOME environment variable, and haven't for some time. Some tools may use it - and if you're using one of those, then sure, set it - but if you're just using (say) Eclipse and the command-line java/javac tools, you're fine without it.

注意,您不需要JAVA_HOME环境变量,而且已经有一段时间不需要了。有些工具可能会使用它——如果您正在使用其中的一个工具,那么当然要设置它——但是如果您只是使用(比如)Eclipse和命令行java/javac工具,那么没有它就没有问题。


1 Yes, this has reminded me that I need to update...

是的,这提醒我我需要更新……

#4


16  

“Java”不被视为内部或外部命令

Step 1. Open your windows property i.e. (windows+Pause Break) then goto Advance System setting . 2. select Advance Tab---> Env.variable --> add variable as shown in figure. Now Open your command prompt and check for: 1. java 2. Javac are executing successfully. If still error is there i.e. "java' is not recognized as an internal or external command" then check whether you have installed jdk twice. If yes then uninstall and follow above step.

步骤1。打开你的windows属性,也就是(windows+Pause Break),然后继续升级系统设置。2。选择预先选项卡- - - > Env。变量——>添加变量,如图所示。现在打开命令提示符并检查:1。java 2。Javac是成功执行。如果仍然存在错误,也就是。“java”不被识别为内部或外部命令”,然后检查您是否安装了两次jdk。如果是,则卸载并执行上述步骤。

#5


4  

For me its start working after putting ,: in the starting of the system variable path :--


“Java”不被视为内部或外部命令

对于我来说,它在put之后开始工作,在系统变量路径的开始:—

“Java”不被视为内部或外部命令


#6


3  

This problem is on Windows 8. First copy your Path of java jdk - e.g. C:\Program Files\Java\jdk1.7.0_51\bin.

这个问题出现在Windows 8上。首先复制你的java jdk的道路——例如C:\Program Files\Java\ jdk1.7.0_51 \ bin。

  1. Right on the My Computer Icon on the Desktop and Click Properties.

    在桌面上的My Computer图标上单击Properties。

  2. Select 'Advanced System Settings' in the left pane.

    在左边窗格中选择“高级系统设置”。

  3. Under 'Advanced' tab, select 'Environment Variables' at the bottom.

    在“高级”选项卡下,在底部选择“环境变量”。

  4. In System Variables, select 'Path' Variable and edit it.

    在系统变量中,选择“Path”变量并对其进行编辑。

Paste the path and add a ';' at the end - e.g. C:\Program Files\Java\jdk1.7.0_51\bin;

粘贴的路径,并添加一个“;”结束时——例如C:\Program Files\Java\ jdk1.7.0_51 \ bin。

#7


1  

I had the same problem. Just Install the exact bit of java as of your computer. If your PC is 64 bit then install 64 bit java. If it is 32 bit then vice versa :)

我也有同样的问题。只需安装您的计算机的确切的java字节。如果你的电脑是64位,然后安装64位java。如果是32位,反之亦然:)

#8


0  

if you have cygwin installed in the Windows Box, or using UNIX Shell then

如果您已经在Windows Box中安装了cygwin,或者使用了UNIX Shell

Issue bash#which java

This will tell you whether java is in your classpath or NOT.

这将告诉您java是否在类路径中。

#9


0  

In my case, PATH was properly SET but PATHEXT has been cleared by me by mistake with .exe extension. That why window can't find java or anything .exe application from command prompt. Hope it can help someone.

在我的例子中,路径被正确设置,但是我错误地用.exe扩展清除了PATHEXT。这就是为什么窗口不能从命令提示符找到java或任何。exe应用程序。希望它能帮助某人。

#10


0  

I had this problem too.finally i solve it.you should enter a space between 'java' and '-'. i.e you should enter 'java -version' in cmd.

我也有这个问题。最后我解决它。您应该在“java”和“-”之间输入空格。我。你应该在cmd中输入“java -version”。

#11


0  

I did all of it, and it didn't work for me, but , finally, I found where I was mistaking all that time :). I didn't type "space" between java and -version. It should be typed like this: java -version. With space between "java" and "-version". Now it works for me.

我做了所有的事情,但这对我来说并不管用,但最终,我找到了我一直在犯错的地方:我没有在java和-version之间输入“空格”。它的类型应该是:java -version。在“java”和“-version”之间有空格。现在它对我很有效。

#12


-1  

My solution was to put same value (path to JDK bin folder) in JAVA_HOME and Path

我的解决方案是将相同的值(到JDK bin文件夹的路径)放在JAVA_HOME和path中

“Java”不被视为内部或外部命令“Java”不被视为内部或外部命令