-
Realjenius.com is ChangingR.J. LorimerTue, Sep 8 2009 @ 3:54 am
-
FriendFeed's Pseudo-ODBR.J. LorimerFri, Feb 27 2009 @ 11:29 pm
-
RubotoR.J. LorimerThu, Feb 26 2009 @ 4:33 pm
-
Constructor CompletionR.J. LorimerTue, Jan 20 2009 @ 3:44 pm
-
The Call of ChrismathuluR.J. LorimerFri, Nov 7 2008 @ 2:38 pm
Getting Started With Eclipse and Groovy
The Groovy Programming Language reached 1.0 status ( as was announced at Javalobby ), and certainly, Groovy has a lot of potential for Java developers looking for the flexibility and speed-of-development of a scripting language without having to be in a completely unfamiliar syntax or set of libraries. Groovy is specifically written to be easy for Java developers to learn and understand, and also integrates very well with Java at deploy-time as well as runtime. Another added benefit of Groovy (and one that I want to discuss here) is that it integrates very well with IDEs; most notably, Eclipse .
To install the Groovy plug-in set for Eclipse, you simply need to point your Eclipse installation to the update site referenced in the Groovy Eclipse Plugin homepage (at the time of this writing the update site is http://dist.codehaus.org/groovy/distributions/update/).
Once you have the groovy support installed, it's very straightforward to use. You can add a Groovy class to any Java project in the same way you would add a Java class; the first thing you'll want to do however, is add the 'groovy nature' to your Java project. To do that, right click on the project, and click 'Add Groovy Nature':
Once that is done, you should see that various libraries have been added to your project, and groovy has it's own binary folder now.
(As you can probably see, the current build of the Eclipse plug-in at the time of this reading ships with Groovy 1.0 RC1 as opposed to 1.0 final - so a build from around 12/16/06; expect this to be changed in the very near future, but if you can't wait, you can always follow the instructions from their plug-in homepage which describe how to build the plug-in from version control)
Now, to create a new Groovy class, simply right click and go to new (or use the new super-selector if you are in a newer version of Eclipse ) and select 'Groovy Class'.
Once done, you will be presented with the new class in the editor.
One of the neat features of Groovy is that it can be executed at request time, or it can be pre-compiled into regular Java class files, and embedded in to a project. This can be seen by the fact that you can run the GroovyTest class from the binary folder as a Java application:
Because of the way Groovy compiles into classfiles on your Java project's classpath, you can immediately interact with them from regular Java classes:
You can also right click any groovy class directly, and say
'Run As -> Groovy'
:
The next step, of course, is to figure out what you actually want to do with Groovy in your project. That's probably a little beyond the scope of this tip; so I'll leave that as an exercise for the reader.
- Login to post comments
