It is possible to run Groovy on .NET 2.0 using IKVM as a virtual machine. By using IKVM compiler, you can compile your Groovy jar to be a .NET assembly (a DLL file) with the following command:
However, some warning will appear, but you can ignore them. After compilation you should have groovy-all-1.5.0.dll in the current directory.
With the compiled DLL, you can use it as a normal .NET assembly. The following example shows how to add it as a reference for building a simple application. You need the SharpDevelop IDE in this case.
the original post: http://chanwit.blogspot.com/2007/04/groovy-running-fine-on-net.html
We can call .NET classes directly from Groovy scripts. Note that IKVM has the cli prefix for all .NET namespaces. If you want to invoke Console.WriteLine('hello world'), you have to type:
The great thing here is that Groovy can pick a correct .NET method. You can also try:
in the interactive console (the binary in the attachment of this page).
On some machines, there will be a test encoding issue to stop Groovy compiling script files. This seems to be the use of different encoding names between Java and .NET. If you find this kind of error, try specifying "-c" when testing with groovy.ui.GroovyMain class.