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
6 Answers
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

- 22,149
- 6
- 70
- 81
-
1what directory we need to be in, where is you my map – Rishabh Agarwal Feb 06 '18 at 17:00
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

- 47,929
- 21
- 130
- 148
-
I'm not sure that `lib/*.jar` will work -- the link you included says that the right syntax is `lib/*`, which will match all files ending with `.jar` or `.JAR` in that folder. – Gaurav Oct 08 '16 at 22:49
Sorry, I dont know others IDE, but works with me on Eclipse.
Right click on your project, select
Properties/ Java Build Path/ Libraries/ Classpath/ Add External JARs...
Then choose whatever files you need :v

- 131
- 1
- 5
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.

- 17,186
- 14
- 73
- 95
You have to fill the Class-Path parameter of the manifest file of the JAR. The standard documentation explains that very well.

- 7,472
- 7
- 45
- 110
When running a jar or class file specify classpath option

- 460
- 3
- 12
-
1If you're running a jar using `-jar` the classpath option is ignored. – Dave Newton Nov 10 '11 at 19:08