title: How to execute a script (an executable class) located inside a Spring MVC project?
body: <p>I'm developing a Spring MVC application and I use Maven. I'm currently trying to create some Java "scripts" (I'm not sure I should call them "scripts", I actually mean "Java classes with a main(String[] args) method" that can be callled on the command line) to do some work using Liquibase.</p>
  
  <p>The "scripts" would load some context files from the Spring MVC application and have access to the properties files from the web application. They will thus be able to use the same database connection settings than the application, etc.</p>
  
  <p>My question is: how to run those scripts?</p>
  
  <p>Locally I'm using Eclipse and running those "scripts" is easy using "Run As / Java Application". But I want to be able to run them on my prod server too, on which I can't use eclipse to start them. What should I do to be able to run them there?</p>
  
  <p>Should I export my application in another format than .war? Should I create an extra .jar from the project to be able to run the scripts using "java -jar"? </p>
  
  <p>Should I create a separate project for those scripts? But then, would the scripts be able to load the required contexts from the Spring MVC application located in the other project?</p>
  
  <p>Maybe there is an easy way to do this that I don't see?</p>
  
  <p><strong>UPDATE</strong> : One way I see I could achieve what I want would be by having the web application to expose  <em>web services</em> as a door to the tasks to run. Then I could call those using <em>wget</em> or something, on the command line. But I'd prefere to be able to reach the classes directly, without the need to create web services.</p>