设置 JAVA_HOME 时出错 [英] Error in setting JAVA_HOME

查看:50
本文介绍了设置 JAVA_HOME 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载了 Maven 并按照此页面上的说明进行操作.我已经在我的机器上安装了 ant.现在,如果我想验证 Maven 是否安装完美,它会给我错误 JAVA_HOME 设置不正确,但同样适用于 ANT.

I have recently downloaded Maven and followed the instructions given on this this page. I already have ant installed on my machine. Now, if I want to verify that Maven is installed perfectly or not it is giving me error that JAVA_HOME is not set correctly, but same works perfectly fine for ANT.

For Maven I tried :
1. open cmd
2. type mvn -version
3. Error appeared :
C:UsersAdmin>mvn -version

ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:Program FilesJavajre7in"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation

For ANT I tried and worked :
1. open cmd
2. type mvn -version
3. Apache Ant(TM) version 1.9.1 compiled on May 15 2013

我去目录检查 java.exe 是否确实存在于该目录中,并且它就在那里.我检查了他们设置的环境变量.我重新启动系统并再次检查但同样的问题.请让我知道我错过了什么.

I went to the directory to check that java.exe is actually there in that directory or not and it was there. I checked the environment variables they set fine. I restarted the system and checked again but same problem. Please let me know what am I missing.

推荐答案

JAVA_HOME 应该指向 jdk 目录而不是 jre 目录.另外 JAVA_HOME 应该指向 jdk 主目录,而不是 jdk/bin 目录.

JAVA_HOME should point to jdk directory and not to jre directory. Also JAVA_HOME should point to the home jdk directory and not to jdk/bin directory.

假设您的程序文件目录中安装了 JDK,那么您需要像这样设置 JAVA_HOME:

Assuming that you have JDK installed in your program files directory then you need to set the JAVA_HOME like this:

JAVA_HOME="C:Program FilesJavajdkxxx"

xxx 是 jdk 版本

xxx is the jdk version

点击此链接了解有关设置 JAVA_HOME 的更多信息:

Follow this link to learn more about setting JAVA_HOME:

http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html

这篇关于设置 JAVA_HOME 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆