简体   繁体   English

如何在批处理文件中添加jar文件引用?

[英]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. 我创建了一个简单的java类文件,用于向用户显示一些文本。
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? 我也尝试通过创建类文件的jar文件来进行尝试,但是它也失败了如何添加jar文件引用,以便批处理文件调用它?

Thanks, 谢谢,

What command are you running to launch your jar? 您正在运行什么命令来启动jar? On what environment are you running? 您在什么环境上运行? This is the syntax for setting the classpath on Windows: 这是在Windows上设置类路径的语法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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