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

编程入门 行业动态 更新时间:2024-10-25 18:36:16
本文介绍了无法从Windows PowerShell命令提示符运行Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have Java installed on my machine (the JRE is under C:\Program Files\Java) but I can't run any java command from the Windows PowerShell command prompt.

>>> 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,我无法运行这些命令。

However, I have noticed that Java does work and that I can run Java commands on the old Windows command prompt. Turns out it's only PowerShell where I can't run those commands.

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

I have JRE 7 and I'm using Windows PowerShell on Windows 8.

推荐答案

  • 在运行对话框中,输入 sysdm.cpl
  • 在出现的窗口,导航到高级选项卡。单击 Environment Variables 按钮。
  • 将java安装的位置(bin目录)添加到 PATH 变量。

    • In the run dialog box, enter sysdm.cpl
    • In the window that came up, navigate to Advanced tab. Click on the Environment Variables button.
    • Add the location of your java installation (the bin directory) to the PATH variable.

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

      后跟;

      注意:

      %version% means the java version.

更多推荐

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

本文发布于:2023-11-06 17:23:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564316.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令提示符   Windows   PowerShell   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!