Thanks to Ben for making me Groovier - No Fluff Just Stuff

Thanks to Ben for making me Groovier

Posted by: Venkat Subramaniam on October 2, 2005

In August, at the end of a .NET talk I gave, Ben came up to me saying I should use Notepad2
instead of Notepad
. At that time, I rejected his suggestion.

Here is why. In most of my talks I use either VS.NET (for .NET talks) or IntelliJ IDEA (for Java talks)
for about 95% of the time (I am that crazy guy who likes to codes 85 minutes in a 90 minutes talk).
The only time I use notepad is if I want to jot down a quick reference for the audience. Notepad
works great for that and I saw (and still see) no reason to use anything more than that for that
purpose. I am not a fan of picking a tool for the sake of picking another tool.

Well, today, I want to thank Ben for making that suggestion. I will still use good old notepad for
simple things?it works. But, I took Ben?s advice for a talk I gave this afternoon at the NFJS event
in Calgary.

One of my talks this evening was "Groovy for Java Programmers." I have a number of demos in
that talk. I don?t like to use the groovyconsole?it does not quite feel right, it prints the result in the
console window in the back, it puts some not-so-useful-during-the-demo information on the
bottom window, etc. One think I do like in it is that you press Ctrl+R and it runs your groovy
code. It got me thinking, if I can do that from within notepad that will be cool?then, I don?t have to
switch to the command window to type the script in order to run. But, I don?t think the good old
notepad can help me with that (IDEA has a plugin for groovy but I have not yet upgraded to 5.0,
besides, I want to work with the minimum on this talk).

So, this afternoon I downloaded Notepad2 and did a few silly things to get this working! The one
feature that made this possible is the ability to run a script from within Notepad2. But, I can't
use that feature directly as the console window would not stay up after the script executes.
Here is what I did to keep the console window up after the script runs:

Wrote a simple script (shown below) and saved it into a file named ?runGroovy.bat? in the
C:\Windows\System32 directory:

# runGroovy.bat
echo off
cls
call groovy %1
pause

Then, in Windows Explorer, I right clicked on a sample Example.groovy file that I had created,
clicked on Properties, in the dialog that popped up, clicked on "Change?" button next to "Opens
with", and selected the runGroovy.bat as the program to start with.

In Notepad2, I set the Settings | Save Before Running Tools. Within Notepad2, I wrote a simple
Groovy program as shown below and saved it into c:\examples\Example.groovy file.


Now when I hit Ctrl + L, the following came up:


Now, I make a simple change to the program as shown below:

Then I hit the Ctrl + L again to see this:

When I hit the return key, a console window popped up with the output of the program.

So, you can write code in Notepad2, hit Ctrl + L, and right there run your Groovy code.
It made for a very convenient demo this afternoon in front of a Groovier audience.
Now, that was pretty simple, unless you can show me something simpler on Windows.

Venkat Subramaniam

About Venkat Subramaniam

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, and an instructional professor at the University of Houston.

He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.

Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at agiledeveloper.com. You can reach him by email at venkats@agiledeveloper.com or on twitter at @venkat_s.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »