// shall I write some keywords here to boost search engine ranking?

Sunday, August 03, 2008

Running Groovy from Windows .bat file

Groovy is a popular dynamic language based on Java. To run your Groovy script, the command is:

groovy HelloWorld.groovy
But you may find some problem to execute it from windows .bat file. An example is as below:
groovy HelloWorld.groovy
echo Groovy script execution complete
You will found all subsequent lines in your .bat will never get executed. So for example above, the echo will not get executed.

After searching through the Groovy mailing list, I found the explanation for this:
"The 'groovy' command actually is a batch file whose full name is 'groovy.bat' but under the Windows command prompt it's OK to not specify the '.bat' part. When you don't use 'call' to transfer control to another batch file but just use the name of the file then there's no way to return..."
And there are 2 solutions for this:
1) add 'call' before your 'groovy' command: call groovy HelloWorld.groovy
2) install Groovy by windows installer instead of zip file to get the native launcher.

No comments: