04 Jul 2008, 21:43
Generic-user-small

Rajagopalan Raghavan (5 posts)

groovy> println ‘groovy -v’.execute().text

Exception thrown: java.io.IOException: CreateProcess: groovy -v error=2

java.io.IOException: CreateProcess: groovy -v error=2 at Script18.run(Script18:1)

When I open a command Window ( Win XP) and execute groovy -v, I get
C:\Private Projects\Groovy>groovy -v
Groovy Version: 1.5.4 JVM: 1.5.0_09-b01

What am I doing wrong?

10 Jul 2008, 05:53
Generic-user-small

Vimal Kansal (1 post)

I am also getting the same problem. Author please help, I mean its so frustrating that you start with a book and within first few pages so hit issues with the code. I hope author is not ‘cut and run’ kind of person and responds.

17 Jul 2008, 12:52
Generic-user-small

Andrei Dolganov (1 post)

Try println “cmd /c groovy -v”.execute().text

29 Jul 2008, 18:50
Generic-user-small

Rajagopalan Raghavan (5 posts)

I think the “cmd/c” option is for dos “internal commands” like dir etc. I did try it and it still didn’t work for me.

Thanks,
Raghavan

29 Jul 2008, 19:04
Venkatsubramaniam_pragsmall

Venkat Subramaniam (71 posts)

Raghavan, on Windows Visa, within the groovysh I typed
println “cmd /c groovy -v”.execute().text
The session along with response is shown below.

groovy:000> println “cmd /c groovy -v”.execute().text
Groovy Version: 1.6-beta-1-SNAPSHOT JVM: 1.6.0-b105

===> null

Notice the space between cmd and /c and also after /c. Can you try again with the spaces (you can copy and past from above)?

27 Oct 2008, 04:14
Generic-user-small

Levi Yourchuck (1 post)

I too encounter this issue.

I have downloaded Groovy Version 1.5.7.

On the command line I type:
groovy -v
And then I get:
Groovy Version: 1.5.7 JVM: 1.5.0_11

Then on the command line I type:
groovysh
Then in the sh I type:
groovy:000> println “groovy -v”.execute().text
ERROR java.io.IOException: CreateProcess: groovy -v error=2 at groovysh_evaluate.run (groovysh_evaluate:2) ...
groovy:000>

Then I type: (and do get a notepad window up)
groovy:000> println “notepad”.execute()
java.lang.ProcessImpl@29c58e
===> null
groovy:000> println “cmd /c groovy -v”.execute().text

===> null
groovy:000>

But never any “groovy -v” variant is working. Does anyone have some insight? I can type groovy -v directly at the command prompt…

01 Nov 2008, 14:05
Venkatsubramaniam_pragsmall

Venkat Subramaniam (71 posts)

Levi, within groovysh,

println “cmd /c groovy -v”.execute().text

prints the version of groovy for me.

Since that does not work for you, can you try the following within groovysh

println “groovy.bat -v”.execute().text

and see if that works for you?

16 Jul 2011, 14:21
Generic-user-small

B Wan (1 post)

Using Windows 7 Starter
I also got an error as Levi.

groovy:000> println “groovy -v”.execute().text
ERROR java.io.IOException:
Cannot run program “groovy”: CreateProcess error=2, The system cannot find the file specified at groovysh_evaluate.run (groovysh_evaluate:2)...

println “cmd /c groovy -v”.execute().text
and
println “groovy.bat -v”.execute().text
return blank line

println “Groovy version ${org.codehaus.groovy.runtime.InvokerHelper.version}”
and
println “Groovy version “+org.codehaus.groovy.runtime.InvokerHelper.getVersion()
return Groovy version 1.8.0

When I boot to Linux
println “groovy -v”.execute().text
works as it should

  You must be logged in to comment