简体   繁体   English

如何从Java程序调用另一个Java进程

[英]How to invoke one more java process from java program

I want to execute mvn exec:java command from a java program. 我想从Java程序执行mvn exec:java命令。

I tried Runtime and ProcessBuilder API but unbale to acheive. 我尝试了运行时和ProcessBuilder API,但实现起来并不麻烦。

Please help me in this problem. 请帮我解决这个问题。

Regards, Praveen 问候,Praveen

Most probably java can not find "mvn" executable. Java很可能找不到“ mvn”可执行文件。 Maintaing PATH variable and finding executables is a function of a command line shell (cmd, bash, etc..). 维护PATH变量并查找可执行文件是命令行外壳程序(cmd,bash等)的功能。 Runtime.exec() does not use your shell. Runtime.exec()不使用您的外壳。

You need to supply full path to executable for Runtime.exec() to find it. 您需要为Runtime.exec()提供可执行文件的完整路径才能找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM