Jeremy Rayner on java and other stuff.

All | AudioDrama | Chatter | Fun | Groovy | Java | Life

grash: added a command history (jline)
Posted on 28 Oct 2004
Thanks to TheServerSide I have had significant interest in grash, for which I'm very grateful. It's great to see that after only two weeks from the initial idea, I have so many positive suggestions and enhancements to think about.

Marc Prud'hommeaux has directed me towards his wonderful wrapper for streams, called jline, that allows grash to provide line editing and command history.

I have released a new version (grash which now includes this facility by default, both from the command line (java -jar grash.jar) and when embedded. If you have any security issues with this amendment when embedding grash, I have provided a new constructor that allows you to turn this facility off. Marc has very kindly relicensed jline as BSD, so grash is still fully available under an Apache2.0/BSD style license.

On Unix and MacOSX you can simply use the arrow keys to navigate round your most recent commands (on Windows you will have to use CTRL-N/CTRL-P due to an issue in jline). The commands you type are persisted (beyond the session) currently in your home directory in a file cunningly called "~/.grash_history".

I'm quite excited that jline also provides the potential for command line completion (a.k.a. tab completion), this would be a splendid addition which I must look into.

This new release also fixes an issue found by Dave Minter, thanks for the feedback Dave, hopefully you will find things a bit more bulletproof now.

Please keep your thoughts and ideas rolling in, cheers.


28 Oct 2004 |

grash: a unix-like shell for your JVM
Posted on 25 Oct 2004
"If everything in Unix is a file and everything in Java is an Object, wouldn't it be nice if you could explore your Objects in the JVM with the same powerful mechanisms you use in Unix."

My line of thought a couple of weeks ago has led to a small implementation of a shell for the JVM, which I have named grash. The name is derived from the fact that it is based in part on the externally observed behaviour of the bash shell, and that it is written in and exposes to the user the Groovy programming language. Hence 'GRoovy-Again SHell'

Using the concept of a 'current working instance' in place of a 'current working directory' some of the tools in a normal shell already make some sense.

what follows has been adapted from the wonderful Kernighan and Pike

What Objects are out there?

The ls command lists the names (not contents) of Objects:

/ grash$ ls
/ grash$
The names are sorted into alphabetical order , like most commands, has options that may be used to alter its default behavior. The -l option gives a "long" listing that provides more information about each Object:
/ grash$ ls 
-------rw-  junk
--------x  main
------rw-  temp
/ grash$
The string - - - - - - r w - tells who has permission to read and write the Object; in this case there is a public getter and setter for the junk and temp objects.

Printing Objects - cat

Now that you have some Objects, how do you look at their contents? The simplest of all the printing commands is cat . cat prints the contents of the Object name by its argument:
/ grash$ cat junk
To be or not to be
/ grash$ cat temp
That is the question.
/ grash$

A handful of useful methods

Grash exposes the Java and Groovy Libraries to the command line user, providing
/ grash$ cat junk
To be or not to be
/ grash$ cat junk.length()
/ grash$ cat junk.tokenize()
[To, be, or, not, to, be]
/ grash$ cat junk.tokenize().sort()
[To, be, be, not, or, to]
/ grash$


A pipe is a way to connect the output of one expression to the input of another. I have implemented pipelines in the simplest way at the moment.
/ grash$ ls -a | println size()
/ grash$
The expressions in a pipeline currently evaluate one after another, but in order to behave like Unix, concurrent evaluation of the commands in a pipeline would be desired.

The methods are currently called on the result of the previous evaluation, again this should perhaps be a different mechanism, using the current working instance and others.


How do I embed grash in my own programs

  • put grash.jar in your classpath
  • include these lines somewhere in your code (note: you can pass your own input/output streams in the Grash constructor}
import com.javanicus.grash.Grash;
Grash grash = new Grash(myObject);
Thread consoleThread = new Thread(grash);

Under the covers

  • 100% Groovy source, at the moment (although some unit tests on Java will be needed)
  • Object references are currently piped around, rather than streams.
  • The grash command line parser takes precedence over groovy, so any ; | > & symbol will be ignored by the time that groovy sees it.

What's left to do...

  • Everything...
  • I have implemented other features such as cd , ps , pipes, redirects and some advanced options on ls
    • Feel free to play with them.
  • Decisions over pipes:
    • object handles or serialized objects ?
    • Do the methods in the subsequent pipe commands call methods on the result of the former, or methods on the 'current working instance' ?


  • This project is just a baby (born 14 Oct 2004), and is an extrapolation from the concept of file/object equivalence.
  • This project uses Groovy which is still in Beta.
  • grash.jar contains all of groovy-all.jar, to help ease of setup. However a version without included groovy will be available upon request.
  • You won't be able to get STDIN (InputStream) to work if you are running your program from ant and it's derivates.


  • "It's amazing what you can do when you're too stupid to realised that it is impossible to achieve"
  • I have no clue whether this will be useful, I'm just experimenting right now.

I'm looking forward to your comments and ideas

25 Oct 2004 |

London Souvlaki Meetup
Posted on 19 Oct 2004
This morning started as I fought my way against the commuters on London Bridge, into the Regis House (Sun training centre). Cameron gave a nice little talk explaining the concepts surrounding the scalable perfomance concerns of high end J2EE applications.

Jules and Cameron after the Tangosol seminar

Cameron very kindly managed to get at least six people from the seminar to then show their faces at the London Java Meetup.

People at SOS

Some new faces too

A great turnout at tonight's meetup, finally Carlos managed to make it along, yay.

Carlos and Cameron

I Managed to talk to Stuart Ervine who is tackling the task of creating a Swing frontend to his xwork actions, called Pendulum. If you look slightly beyond the coolness of being able to reuse your xwork actions in an app, Stuart is also looking very hard at providing an junit extensions for asserting that your swing application frames have all the right buttons and labels etc.

Stuart and Max

Jules managed to get the chance to explain that WADI is shaping up nicely.

The meetup moved out of SOS as the evening progressed, as Cameron suggested we find solace in a souvlaki bar.

A souvlaki bar in the heart of the city

For those that care, I rambled on about Groovy, grash, thinlets, gnudiff4java, xdelta in java, the freenet routing algorithm, xstream, sitemesh, BBC Emulation on MacOSX, JOGL, and redbook OpenGL examples.

Thanks to Cameron for increasing the fold, and thanks again for the prized Tangosol T-Shirt.

19 Oct 2004 |

London Java Meetup - tonight
Posted on 18 Oct 2004
It's the London Java Meetup this evening. If you haven't been before, then tonight is a good night to join us. Cameron Purdy should be able to make it, which is always fun :-) So if your near London, and want a cheap night out with geeks, look no further.

Hope to see you there

18 Oct 2004 |

Ninja Joe
Posted on 11 Oct 2004
After hearing that Joe would be attempting to backflip down finsbury pavement, like a ninja, I was to say the least a little skeptical.

But Joe persisted and as you can see from this blog entry, he did his research and attempted to raise lots of money for charity.

Did he do it?

Judge for yourself...

Quicktime Movie of Three Back Handsprings (2Mb) and other pics/movies

Well done Joe!

11 Oct 2004 |


October 2004
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Prev | Today | Next

rss:subscribe (All)

What I'm reading
my feed aggregator ->box

My websites
London Java Meetups
Programming Projects
Elite in Java
Jez's Photos
Fantasy Stock Market
Cool Saxophonist
Doctor Who Audios
Pisces Audios

Other Blogs
Mike Cannon-Brookes
James Strachan
Joe Walnes
Sam Dalton
Simon Brown
Cameron Purdy
Mike Roberts
Erik C. Thauvin
John Martin
Manfred Riem

B5 d++ t++ k s+ u- f
i+ o+ x-- e+ l- c--

powered by blogmento