Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

If you want to run your groovy scripts on windows so that they seem like any other commands (i.e. if you have myscript.groovy on your PATH, you can just type myscript), you have to associate groovy script files with the groovy executable. If you use the groovy windows installer it will do this for you. Otherwise, do as follows:

  • add .groovy to PATHEXT environment variable
  • make changes in windows registry as follows
  • run regedit.exe
  • create a new key HKEY_CLASSES_ROOT\.groovy and give it the value groovyFile
  • create HKEY_CLASSES_ROOT\groovyFile
  • under that, create HKEY_CLASSES_ROOT\groovyFile\Shell and give it value open
  • under that, create HKEY_CLASSES_ROOT\groovyFile\Shell\open\command and give it value (adjust according to your groovy location) "c:\programs\groovy-1.0\bin\groovy.exe" "%1" %*

Why?

Why have a native launcher, why aren't the startup scripts (groovy.bat, groovy.sh) sufficient? Here are some reasons:

  • it solves an open bug : return value of groovy (on windows) is always 0 no matter what happens in the executed script ( even if you call System.exit(1) ). Granted, this could be solved by editing the launch scripts also.
  • it is slightly faster than the corresponding .bat / shell script
  • you can mix jvm params and groovy params, thus making it easier and more natural to e.g. reserve more memory for the started jvm.
  • the process will be called "groovy", not "java". Cosmetic, yes, but still nice. = )
  • fixes the problems there have been w/ the .bat launcher and paths w/ whitespace
  • works better on cygwin than the posix launcher script
  • on Linux, you can't use an interpreted script as a #! interpreter, because of a kernel bug

Also, the launcher has been written so that the source can be used to easily create a native launcher for any Java program.

...