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 system cannot find the file specified
at com.example.Greetings.run(Greetings.groovy:23)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
... 1 more

println "groovy -v".execute().text
This didn't work for me on Windows 7. I get the following error.
Caught: java.io.IOException: Cannot run prog...more...

Reported in:
P1.0
(07-Aug-13)

#52340PDF page: 16

You have an example like this:

println "groovy -v".execute().text

You say: "This code sample works on Unix-like systems and on Windows."

However, when I test this out on a Windows machine, I find that it gives the following error:

Caught: java.io.IOException: Cannot run program "groovy": CreateProcess error=2, The system cannot find the file specified

Note that "groovy" does work on my command line; I have GROOVY_HOME set and the GROOVY_HOME\bin on my path. I can run groovy and groovysh from the command line without issue.

You have to do this:

println "cmd /C groovy -v".execute().text

You do mention the need to run 'cmd' directly later on the same page. You mention that you need to do this if you use the "dir" command but that's not true. You can run this:

println "dir".execute().text

without error.

--Jeff Nyman

You have an example like this:
println "groovy -v".execute().text
You say: "This code sample works on Unix-like systems and on Windows."
Ho...more...

Reported in:
P1.0
(09-Aug-13)

#52350PDF page: 16

Instead of the following which doesn't work on windows.
println "groovy -v".execute().text

Instead of the following which doesn't work on windows.
println "groovy -v".execute().text
The following works on windows 7. since it's a shell co...more...

Reported in:
B3.0
(05-Jul-13)

#52124PDF page: 20

A minor point: On p. 20, you compare a Java class containing main() with a Groovy script. I understand your point that in Groovy you can just call a class in a script without using a main() method. However, the two versions are not directly equivalent, precisely because the Groovy script has lost the ability to be the main() function in a program with other modules, whereas the Java program has not. If you want to say the Groovy version is a shorter version of the Java version, I think you should point out that the Groovy version has slightly less capacity. Or perhaps show a second version of the Groovy example using main(). You do the same type of comparison with Java main() classes elsewhere in the book. If you search for "main" you'll find other examples. --Andrew Binstock

A minor point: On p. 20, you compare a Java class containing main() with a Groovy script. I understand your point that in Groovy you can just call a ...more...

Reported in:
P1.0
(08-Aug-13)

#52342PDF page: 22

On this page, you say:

"To take advantage of this feature, define the first parameter as a Map."

However, it's not clear to me that any of the parameters in the Robot class are a Map. A bit further down you say:

"The instance of Robot took type, height, and width parameters as name-value pairs."

Okay, so it "took" them that way -- but I didn't define anything as a Map, did I? This is the part I'm not sure about. The confusion here is probably mine but I wonder if the wording could be clarified?

--Jeff Nyman

On this page, you say:
"To take advantage of this feature, define the first parameter as a Map."
However, it's not clear to me that any of the...more...

Reported in:
P1.0
(08-Aug-13)

#52348PDF page: 26

I recommend an attempt to anticipate how people experiment. For example, on this page, I can try examples like this:

It throws an exception. This is the case even though my parse() method is returning an array, which would seem to make my second example the same as the first.

While I realize my examples are different from yours, they are logically the same and the likely experimentation path of most programmers reading this page. I bring this up because on this page, you say: "If the excess variable is a primitive type, something that can't be set to null,
then Groovy will throw an exception."

But, again, clarifying with example is better than just words, particularly since my experimentation leads to a question as to how things are working.

This is even moreso the case when you consider that this slight variation does work:

That's relevant because notice the third one? Groovy returns nothing at all. Maybe that makes sense to someone. But I'm certainly not sure why that result is the way it is; and this seems like a perfect spot in the book to explain why that is.

--Jeff Nyman

I would consider that some of your readers would experiment and maybe anticipate confusions. For example, on the WhatEquals script, you only run two...more...

Reported in:
P1.0
(16-Aug-13)

#52388PDF page: 50

First paragraph after code block at the top of the page

class name referenced has a typo - Calibrartor instead of Calibrator.
--Shannon Pieper

Chapter 7 (Exploring the GDK) under section 7.3: Custom Methods Using the Extension Modules. In Extension/FindPrice.groovy, the static and instance me...more...

Reported in:
P1.0
(25-Aug-13)

#52462PDF page: 141

Possible swapping of instance vs. static methods - just the labeling with the println of which method is static and which is instance. First one is labeled as instance but is static and vice-versa on the second println.--Shannon Pieper

Possible swapping of instance vs. static methods - just the labeling with the println of which method is static and which is instance. First one is l...more...

Reported in:
P1.0
(14-Mar-15)

#78250Paper page: 152

At end of section 9.1, command to create the database without password should be:
mysql -u root < createdb.sql

..or with password:
mysql -u root -p < createdb.sql

It does not work with the equals sign.--Peter Sarazin

At end of section 9.1, command to create the database without password should be:
mysql -u root < createdb.sql
..or with password:
mysql -u root ...more...

Reported in:
P1.0
(07-Mar-14)

#76493PDF page: 253

Last paragraph sentence:
Let’s look at an example of creating XML documents in Groov using a builder:
should have Groovy instead of Groov
--Eugene Masterov

Last paragraph sentence:
Let’s look at an example of creating XML documents in Groov using a builder:
should have Groovy instead of Groov
--Eugene ...more...

Reported in:
P1.0
(09-Aug-13)

#52353PDF page: 281

At this point in the book, when I run the test you have described, it does not pass as this page says it should. Rather I get this:

It looks to me like the someAction method in CodeWithHeavierDependenciesExt is not actually being executed.

If I put output lines in both someAction() methods, I'm finding that only the one in the original class, not the Ext class, is executing.

--Jeff Nyman

At this point in the book, when I run the test you have described, it does not pass as this page says it should. Rather I get this:
testMyMethod(...more...

Reported in:
P1.0
(09-Aug-13)

#52354PDF page: 281

(I really wish these errata sections had an edit aspect so you can edit your own previous entries.)

For the last one I posted on page 281 -- (entry by Jeff Nyman) -- it appears I was running the Java code version and that's why I was seeing the error I was seeing. Part of the challenge is I was also going through the code from the downloadable distribution which has a ton of files in it. So the problem I report here is actually for the test that appears on page 282 and 283.

--Jeff Nyman

(I really wish these errata sections had an edit aspect so you can edit your own previous entries.)
For the last one I posted on page 281 -- (ent...more...

Reported in:
B3.0
(05-Jul-13)

#52125PDF page: 400

No example of main() in Groovy anywhere in the book? Seems like an important omission. --Andrew Binstock

Reported in:
P1.0
(20-Mar-14)

#76552PDF page: 1741

Note that the page number (1741) entered is the Kindle edition's Location.

In the section about '==' in groovy versus java (WhatEquals.groovy is the source code) it would be good to mention that the operand on the left decides whether compareTo or equals is called.

So, in your example, new A() == new B() would output 'equals called' whereas new B() == new A() would output 'compareTo called'

Also note that if the objects are in fact the same reference, neither equals nor compareTo are called:

def a = new A()
a == a // no output from this

--Steve Loker

Note that the page number (1741) entered is the Kindle edition's Location.
In the section about '==' in groovy versus java (WhatEquals.groovy is th...more...