simple groovy program fails with error: No signature of method: java.lang.ProcessBuilder.inheritIO() is applicable for argument types: () values: []

StackOverflow https://stackoverflow.com/questions/23468347

  •  15-07-2023
  •  | 
  •  

Question

I'm scratching my head on this one, The program is as follows:

class MyClass {
    def static someMethod() {
        def pb = new ProcessBuilder("")
        pb.inheritIO()
        pb.setCommand(/* command list */)
        def process = pb.start()
        ...
        println "profit"
    }
}

except running the above (or the equivelant of) gives the output:

No signature of method: java.lang.ProcessBuilder.inheritIO() is applicable for argument types: () values: []

inheritIO is obviously a method defined in the ProcessBuilder class

so what is going wrong here?

CONTEXT: this is happening during a gradle build using jdk 7u55 except i imagine this info is unrelated. to me it looks like groovy has forgotten what it was doing.

EDIT: if i delete the pb.inheritIO() line then when i call pb.start() it throws another error:

java.lang.ArrayStoreException
Was it helpful?

Solution

Turns out the answer is quite involved but very specific to my setup:

although i have my org.gradle.java.home property set to the java 1.7 jdk, I am using a properties plugin that uses different property files according to an environment variable called environmentName this property was set to the incorrect value thus it was reading JAVA_HOME from my environment rather than the variable i set in the property file i wanted. I changed this and the jre was switched to the correct runtime.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top