Monday, March 28, 2011

Running jar file with source files in another directory

I would like to run a jar file right from the command line without having to put the jar file in the directory containing my input files. Any ideas on how I can do this if it is possible?

From stackoverflow
  • Wouldn't you just supply a class path argument when executing the class inside of the JAR? For example:

    java -cp lib/somejar.jar org.foo.bar.MyClass

    Where -cp is the classpath argument and lib/somejar.jar is the path to the jar you are trying to execute.

    I'm not sure I'm clear on what you're looking for.

    Amara : Thank you. Sorry if I wasn't clear enough - wasn't aware that I could supply a class path argument.
    toddk : No problem - glad I could help. :-)

0 comments:

Post a Comment