简体   繁体   English

JAVA类路径传递文件作为命令行参数

[英]JAVA classpath pass file as command line argument

I have a program which is located in 我有一个程序位于

say

$A430CLASS/com.airbus.adcsip.batch.GlobalReportBatch

$A430CLASS is the path where my class file is present. $ A430CLASS是类文件所在的路径。

i want to run it through shell script so i entered following command : 我想通过外壳脚本运行它,所以我输入以下命令:

java -classpath $A430CLASS/com.airbus.adcsip.batch.GlobalReportBatch $A430CONF/batch.properties

$A430CONF is the path where the batch.properties file is present. $ A430CONF是存在batch.properties文件的路径。 GlobalReportBatch is my class file name As you can see i want to pass this batch.properties file as argument to my java program. GlobalReportBatch是我的类文件名如您所见,我想将此batch.properties文件作为参数传递给我的Java程序。 but when i run my script it tries to replace "." 但是当我运行我的脚本时,它将尝试替换“。” in batch.props file to "/" it gives me NoClassDefFound error. 在batch.props文件中添加到“ /”,它给我NoClassDefFound错误。

What you put after the -classpath option must be a list of directories and JAR files, separated by : (on Unix-like operating systems) or ; -classpath选项之后放置的内容必须是目录和JAR文件的列表,并用:在类Unix操作系统上)或;分隔; (on Windows). (在Windows上)。

Look at what you are passing: 看一下您正在传递的内容:

-classpath $A430CLASS/com.airbus.adcsip.batch.GlobalReportBatch

Remove the slash / between $A430CLASS and your class name; 删除$A430CLASS和您的类名之间的斜杠/ replace it by a space: 用空格代替:

-classpath $A430CLASS com.airbus.adcsip.batch.GlobalReportBatch

So the entire line becomes: 因此,整个行变为:

java -classpath $A430CLASS com.airbus.adcsip.batch.GlobalReportBatch $A430CONF/batch.properties

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

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