<p>How would I go about writing some code to allow access to a Java class in my webapp from the command line.</p>

<p>E.g. I have a java class with command line interface, that can runs code in the context of the webapp, with access to the DB etc. I want to log on the machine hosting my WARred app in tomcat and be able to interact with it </p>

<p>Where should i start looking ?</p>

<p>Thanks </p>

A suggestion:
Your command line interface class should accept an InputStream as it's input and provide an OutputStream (it can't hardcode output to System.out and input to System.in) that it's output will be written to.  Then you'll have to write a server class that listens for connections on a certain port.  When a connection is made the server would take the InputStream from the connection and give it to the command line class which would provide the OutputStream that data written to will be passed to the client that made the connection.