我的机器上安装了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
发布评论