Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从 java 程序执行mvn exec:java命令。
我尝试了 Runtime 和 ProcessBuilder API,但无法实现。
请帮我解决这个问题。
问候, 普拉文
很可能java找不到“mvn”可执行文件。维护 PATH 变量和查找可执行文件是命令行 shell(cmd、bash 等)的功能。Runtime.exec() 不使用您的外壳。
您需要为 Runtime.exec() 提供可执行文件的完整路径才能找到它。