Sunday, June 5, 2011

Java: include a jar file during compilation

Share at Facebook

There are lots of geeks who don't use IDE for doing Java. I am one of those freaks. If you need to use additional Jar file with your Java source, you can do this by two ways.

1) adding the jar file at compile time.
javac -cp '.;lib/*;c:/lib/anotherdir/*'

This will include all the jar files from the lib directory of the current path, and the jar files from the c:/lib/anotherdir/ path.

2) using the jar file names at classpath environment variable.

No comments: