java Apache Maven 无法在 cmd 中工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34752813/
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
Apache maven not working in cmd
提问by AIK
Recently I downloaded the apache maven 3.3.9 zip and extracted it to my D:\ directory but when I run mvn -version or mvn in cmd sometimes it gives me the error mvn is not an internal or external command
and sometimes JAVA_HOME is not set properly. However I checked by echo %JAVA_HOME%
that it points to the right location of my jdk which is in my C:\ directory. I also inserted variables in user and environment variables. I run cmd as administrator. I have tried almost everything but nothing works. Can anyone please tell me how to fix this problem? It would be really appreciated. Thanks.
最近我下载了 apache maven 3.3.9 zip 并将其解压缩到我的 D:\ 目录,但是当我在 cmd 中运行 mvn -version 或 mvn 时,它有时会给我错误mvn is not an internal or external command
,有时 JAVA_HOME 设置不正确。但是我检查echo %JAVA_HOME%
它是否指向我的 jdk 的正确位置,该位置在我的 C:\ 目录中。我还在用户和环境变量中插入了变量。我以管理员身份运行 cmd。我几乎尝试了所有方法,但没有任何效果。谁能告诉我如何解决这个问题?真的很感激。谢谢。
回答by jah
回答by Foxy
Open command line, type "set" and hit enter, it will give you list of environment variables. Search for M2_HOME and JAVA_HOME. If they don't exist then you need to right click My Computer--> Properties --> Advanced --> Environment variables. Add M2_HOME and JAVA_HOME environment variables there.
打开命令行,输入“set”并回车,它会给你环境变量列表。搜索 M2_HOME 和 JAVA_HOME。如果它们不存在,那么您需要右键单击我的电脑--> 属性--> 高级--> 环境变量。在那里添加 M2_HOME 和 JAVA_HOME 环境变量。
First, add JAVA_HOME, you need to click on User variables, add new variable and set it to your java directory, for example: "C:\Program Files\Java\jdk1.7.0_75"
首先添加JAVA_HOME,你需要点击User variables,添加新变量并设置到你的java目录下,例如:“C:\Program Files\Java\jdk1.7.0_75”
Then add Java compiler location to System Path by clicking System Variables, choose Path, click edit and set it to java directory on your system. Make sure that path to compiler location ends with "/bin", like here: "C:\Program Files\Java\jdk1.7.0_75\bin"
然后通过单击系统变量将 Java 编译器位置添加到系统路径,选择路径,单击编辑并将其设置为系统上的 java 目录。确保编译器位置的路径以“/bin”结尾,例如:“C:\Program Files\Java\jdk1.7.0_75\bin”
To add M2_HOME do the same, set it to your location, for example: "C:\Program Files\Apache Software Foundation\apache-maven-3.3.3".
要添加 M2_HOME,请执行相同操作,将其设置为您的位置,例如:“C:\Program Files\Apache Software Foundation\apache-maven-3.3.3”。
When you done, verify it on command line: mvn --version
完成后,在命令行上验证它: mvn --version