简体   繁体   中英

How to add jar file reference in a batch file?

I have created a simple java class file say for displaying some text to user.
I have created the batch file for this program.
It is working fine when i placed it to same directory where my class file exists
but when i placed it somewhere else it is giving file not found exception or class not found exception and fails to display the text to user.
How this can be resolved?

I have tried also by creating the jar file of my class file but also it fails how can i add a jar file reference so that batch file invokes it?

Thanks,

What command are you running to launch your jar? On what environment are you running? This is the syntax for setting the classpath on Windows:

java -cp "./yourJar.jar;otherJars" your.class.with.Main

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM