Compiling Java With an External Jar From the Command Line

It took me a while to firgure this out, but I’m sure someone else will find it useful. In order to compile from the command line, you need to set the classpath of the jar, when you compile, and run the class. Here is an example:

javac -classpath .:/pathtojar/jarname.jar ClassName.java

java -classpath .:/pathtojar/jarname.jar ClassName

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">