Including jar files in class path

I m running a java program from a batch file which refences some external jar files .How do i include those jar files in my batch file.Please help


Look at the Sun's official documentation: Setting the class path to understand your options.

A quick way would be just to include your JAR(s) after the -cp:

on Windows

java -cp C:\java\MyClasses\myclasses.jar;C:\java\MyClasses\myclassesAnother.jar utility.myapp.Cool

on Linux/Unix

java -cp /opt/thirdparty/myclasses.jar:/opt/thirdparty/myclassesAnother.jar utility.myapp.Cool

You need to set classpath http://download.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html. E.g.,

java -cp file1.jar;file2.jar yourApp

or if your jar-files are located in directory lib/

java -cp lib/* yourApp

Not to bother with -classpath parameter you could put references to the jar files into the manifest.mf of your application JAR, if it's you application of course.

Adding Classes to the JAR File's Classpath