无法从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
# 1 楼答案
将java安装的位置(bin目录)添加到路径变量中
然后是
;
注:
# 2 楼答案
您需要设置Java类路径:
参考:
How to set class path?
或者:
Link-2: How to set class path?