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
As of Java 6, extension JAR files may also be placed in a location that is independent of any particular JRE, so that extensions can be shared by all JREs that are installed on a system. It says that for Windows you should place your extensions here %SystemRoot%\Sun\Java\lib\ext .
To check our CLASSPATH on Windows we can open a command prompt and type echo %CLASSPATH%. To check it on a Mac you need to open a terminal and type echo $CLASSPATH.
To run an application in a nonexecutable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: java -cp jar-file-name main-class-name [args …]
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
:
java -cp C:\java\MyClasses\myclasses.jar;C:\java\MyClasses\myclassesAnother.jar utility.myapp.Cool
java -cp /opt/thirdparty/myclasses.jar:/opt/thirdparty/myclassesAnother.jar utility.myapp.Cool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With