有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

无法从Windows PowerShell命令提示符运行Java

我的机器上安装了Java(JRE在C:\Program Files\Java下),但我无法从Windows PowerShell命令提示符运行任何Java命令

>>> java -version
java : The term 'java' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ java
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (java:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

然而,我注意到Java确实可以工作,而且我可以在旧的Windows命令提示符下运行Java命令。事实证明,这是唯一一个我无法运行这些命令的PowerShell

我有JRE 7,在Windows 8上使用Windows PowerShell


共 (2) 个答案

  1. # 1 楼答案

    • 在“运行”对话框中,输入sysdm。cpl
    • 在弹出的窗口中,导航到高级选项卡。点击环境变量按钮
    • 将java安装的位置(bin目录)添加到路径变量中

      ;%ProgramFiles%/Java/jre%version%/bin
      

      然后是;

    注:

    %version% means the java version.