Maven 和 Java_Home
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20735093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven and Java_Home
提问by javaz
I am using Netbeans 7.4. I down loaded the Maven3.1 and extracted in C:\Apache\apache-maven-3.1.1. System Variables are set as :
我正在使用 Netbeans 7.4。我下载了 Maven3.1 并解压到 C:\Apache\apache-maven-3.1.1。系统变量设置为:
JAVA_HOME is set at C:\Program Files\Java\jdk1.7.0_45 M2_HOME is set to C:\Apache\apache-maven-3.1.1
Path is set to C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.7.0_45\bin;%M2_HOME%\bin
JAVA_HOME 设置为 C:\Program Files\Java\jdk1.7.0_45 M2_HOME 设置为 C:\Apache\apache-maven-3.1.1
路径设置为 C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\ Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C: \Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.7.0_45\bin;%M2_HOME%\bin
Now when from the command line I command ..>mvn -v I get this this error:
现在,当我从命令行命令 ..>mvn -v 时,我收到此错误:
ERROR: JAVA_HOME is set to an invalid directory. JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_45;" Please set the JAVA_HOME variable in your environment to match the location of your Java installation
错误:JAVA_HOME 设置为无效目录。JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_45;" 请在您的环境中设置 JAVA_HOME 变量以匹配您的 Java 安装位置
回答by Keeto
Java\jdk* is the installation directory of the development kit. Find a "jre" folder inside Program Files\Java. That "JRE" folder should be your JAVA_HOME
Java\jdk* 是开发包的安装目录。在 Program Files\Java 中找到一个“jre”文件夹。那个“JRE”文件夹应该是你的 JAVA_HOME
回答by Robert Scholte
The value JAVA_HOME
should notcontain quotes, because several Maven plugins will append something like 'bin\javac.exe', which would give an invalid path if the quotes are still there.
该值JAVA_HOME
应不包含引号,因为有几个Maven插件将追加类似“本\的javac.exe”,如果行情仍然存在,这将使无效的路径。
回答by Marcos
Actually you need to create
其实你需要创建
system variable like this:
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_45
CLASS_PATH = C:\Program Files\Java\jdk1.7.0_45\bin\lib
User variable
ME = C:\Program Files\apache-maven-3.1.1\bin
M2_HOME = C:\Program Files\apache-maven-3.1.1
MAVEN_OPTS = -Xms256m -Xmx512m
Path - insert into your path
C:\Program Files\apache-maven-3.1.1\bin
Don't forget to reboot system
别忘了重启系统
回答by Stephen C
Read the error message carefully. It says:
仔细阅读错误消息。它说:
... JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_45;" ...
See the stray semicolon? Get rid of it!
看到杂散的分号了吗?摆脱它!
The JAVA_HOME variable should contain a directory name ... not a "search path". What you are telling Maven to do is to use a directory whose name contains a semicolon. That directory doesn't exist.
JAVA_HOME 变量应该包含一个目录名......而不是一个“搜索路径”。您告诉 Maven 要做的是使用名称包含分号的目录。该目录不存在。
Meta-advice: it pays to read error messages carefully.
元建议:仔细阅读错误消息是值得的。
回答by Chinmoy
I faced the similar situation. I resolved it by removing the semicolon(;) at the end of JAVA_HOME
.
我遇到了类似的情况。我通过删除JAVA_HOME
.
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_11
Instead of
代替
JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_11;"