Running Maven from Java code in Windows?

前端 未结 4 860
名媛妹妹
名媛妹妹 2021-01-05 11:21

I am trying to run maven from my java class based on this suggestion:

How to run maven from java?

Runtime.getRuntime().exec(\"mvn\");
4条回答
  •  情书的邮戳
    2021-01-05 11:35

    Error 2 means that the executable cannot be found by the JRE environment. This means that the PATH environment variable does not contain the Maven binary directory.

    2 choices here:

    1. Make sure that the Maven bin directory is in the PATH environment variable
    2. Use an absolute path to the mvn command.

    Alternatively, this could also be due to a permission denied, but it is less likely the case.

提交回复
热议问题