2

In my Java application, I want to execute a python script with Process class. This python script needs to execute svn command. It seems that the PATH variable in my java application doesn't include /usr/local/bin. While I installed SVN 1.7.9 with homebrew and it's in /usr/local/bin. In the /usr/bin folder, there is another svn installed by xcode whose version is 1.6.x. This leads to a serious problem: when I execute the python script in my Java application, this script then executes svn in /usr/bin which is version 1.6.x. This version is too old to manage my working copy.

Is there any way to solve this problem?

4

1 回答 1

4

Either set the PATH environment variable before you launch your (parent) Java application, or use ProcessBuilder. The latter allows you to control what the child processes environment will contain via the Map object returned by the ProcessBuilder.environment() method.

(But note that you typically can't change the contents of the child processes environment once it has been started ...)

于 2013-05-23T09:24:53.117 回答