Maven 1.0.2和JDK 1.6问题

时间:2012-02-12 14:37:14

标签: maven jdk1.6

我使用Maven 1.0.2和JDK 1.5一段时间没有任何问题。我决定迁移到JDK 1.6,因此我更改了JAVA_HOME环境变量(在Windows 7系统上),现在我在尝试使用maven(例如cmd中的maven install命令)时收到一条奇怪的错误消息。

java.io.IOException: Cannot run program "command.com": CreateProcess error=2, the
system could not find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at java.lang.Runtime.exec(Runtime.java:593)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:646)
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:416)
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:427)
    at org.apache.tools.ant.taskdefs.Execute.getProcEnvironment(Execute.java
:180)
    at org.apache.tools.ant.taskdefs.Property.loadEnvironment(Property.java:
455)
    at org.apache.tools.ant.taskdefs.Property.execute(Property.java:359)
    at org.apache.tools.ant.Task.perform(Task.java:341)
    at org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
    at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
    at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
    at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
    at com.werken.werkz.jelly.ProjectTag.doTag(ProjectTag.java:112)
    at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
    at org.apache.maven.plugin.PluginManager.runScript(PluginManager.java:11
43)
    at org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:
647)
    at org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
    at org.apache.maven.cli.App.doMain(App.java:488)
    at org.apache.maven.cli.App.main(App.java:1239)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.werken.forehead.Forehead.run(Forehead.java:551)
    at com.werken.forehead.Forehead.main(Forehead.java:581)
Caused by: java.io.IOException: CreateProcess error=2, O sistema nÒo pode encont
rar o arquivo especificado
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)

Windows 7上没有command.com文件,而是cmd.exe。我不知道为什么maven只在我指向JDK 1.6时搜索它。如果我将JAVA_HOME指向JDK 1.5,一切都恢复正常。怎么了?感谢。

1 个答案:

答案 0 :(得分:5)

windows 7 x64没有command.com,因为它是16位应用程序我有同样的问题,我的一个朋友发现了一个很棒的解决方案

复制cmd.exe并将副本重命名为command.com,将其放在路径

问题解决了!!!