我一直在尝试在String
上使用Groovy的exectue()函数String command = "groovy -e \"print \'Groovy\'\""
println command
println command.execute().text
我收到了这个输出:
groovy -e "print 'Groovy'"
Caught: java.io.IOException: Cannot run program "groovy": CreateProcess error=2,
The system cannot find the file specified
java.io.IOException: Cannot run program "groovy": CreateProcess error=2, The sys
tem cannot find the file specified
at ProcessParameters.run(ProcessParameters.groovy:6)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
e file specified
... 1 more
即使我通过命令行执行: groovy SimpleExample.groovy 运行代码。
这是通过cmd终端在Windows 7计算机上。 groovy版本2.1.8 JVM:1.7.0_04