Java exploratory programming

Sometime you just need to test some external libraries – how they work. In Java I was always creating some file, compile it and test, then I want to change something, compile, test. Not comfortable at all!!

Today I had a need to check how Joda-time library working with periods, to test correctness of implementation of iso8601 in Erlang. Surprisingly, I found an article about jrunscript (my bad that I didn’t knew about it, but maybe somebody else don’t know either).
With this tool it was quite easy to experiment with Joda-time library:

jrunscript -cp ./joda-time-1.6.jar
js> importPackage(org.joda.time);
js> var date = new DateTime("2010-01-31");
js> date
2010-01-31T00:00:00.000+02:00
js> var oneMonthAndSecond = new Period().withMonths(1).withSeconds(1);
js> oneMonthAndSecond;
P1MT1S
js> date.plus(oneMonthAndSecond);
2010-02-28T00:00:01.000+02:00
js>

It is usable when you want to debug regular expression, test some new library, etc etc etc. I found this quite comfortable for myself.