Friday, July 2, 2010

Java based Shell Commands

The ultimate goal is to produce java command classes that run on the unix command line looking like any other shell script in its usage. This means the Java application must parse command line arguments. In java there is usually a library that already exists to accomplish standard bits of functionality. Parsing the command line is no exception, I found the args4j library to help parse command line arguments.
You can find it at:

args4j

The library uses Java 5 attributes to tag fields in the class that will represent the values of the command line arguments once parsed. The library will parse the arguments and sets the field attributes of the class. Now the programmer only needs to reference those values at the appropriate time. It's all quite easy.

No comments:

Post a Comment