java找不到命令,找不到Java命令

在尝试运行java命令时遇到了'java'不是内部或外部命令的错误。检查了系统环境变量,发现PATH变量指向了'javapath',该文件夹中有三个文件。尽管创建了新的快捷方式'java2'可以短暂打开命令窗口,但在命令提示符中使用'java2-version'仍然报错。已确认安装了Java 8且安装正确,操作系统为64位Windows 7。问题可能出在环境变量配置上。
摘要由CSDN通过智能技术生成

I'm trying to get the java command to work on my computer. Whenever I try to use it, I get the error "'java' is not recognized as an internal or..."

What I've done

So far I've traced the issue through my system environment variables, which has a variable PATH that links to "C:\ProgramData\Oracle\Java\javapath" or javapath for short.

There are 3 files in the javapath folder, and if you click on them a popup says:

B3YFz.png

But when I examine the properties of the shortcut and click "open folder location" it sends me to the right place (?? what is this).

Just in case, I tried to recreate the shortcut; I called it java2 and it now works (opens a command box for a split second and closes) when I click on it. However, testing it in command prompt with the line "java2 -version" returns "'java2' is not recognized as an internal or external..."

Details

I just installed java 8, and I've verified that it was installed correctly

I'm running a 64 bit windows 7 OS

解决方案

Have you checked your environment variables for Windows? When you installed the JDK/JRE the directory should have been added to the PATH variable. The directory added needs to contain the java.exe executable. It should be located in C:\Program Files\Java or something like that if you installed it using the default settings. Once you find that directory find the bin directory inside it.

In order to check that:

Right click My Computer and hit Properties

On the left side hit Advanced System Settings

Hit the Advanced tab and then Environment Variables down at the bottom

Find the PATH variable and then hit edit. Confirm that the location of the JDK /bin directory is there, if it is not then add it.

Also, if the JAVA_HOME variable isn't already set, this may be a good idea.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值