Junit 4.x and IDEA 8.0.1 build 9164 - Runtime.exec("env") is not found

Mac OS X 10.5.5
JDK 15 and 16

Running a unit test that invokes the Runtime.exec("env") results in a exception
java.io.IOException: env: not found
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:52)
        at java.lang.ProcessImpl.start(ProcessImpl.java:91)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
        at java.lang.Runtime.exec(Runtime.java:591)
        at java.lang.Runtime.exec(Runtime.java:429)
        at java.lang.Runtime.exec(Runtime.java:326)


It seems junit plugin doesn't seem to be passed to OS handler or something like that.

Note that running the application (without unit test)  that touches the code works just fine. Also IDEA 7.x worked fine as well.

I downloaded and tried Diana has the same issue.

I posted this to tech support but posting here as well for benefit of others to the solution.

Any ideas any one ?

1 comment
Comment actions Permalink

Hello.

I tried the following dummy class:

public class ExecTest {
    @Test public void testRuntime() throws Exception {
        Process process = Runtime.getRuntime().exec("env");
        Thread.sleep(2000L);
        System.out.println(process.exitValue());
    }
}

It terminates normally and does not throw any exceptions.(Mac 10.5.6, JDK 1.6.) If you run such simple class, does the error happen to you?

Alexander.

0

Please sign in to leave a comment.