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

时间:2012-10-03 13:42:08

标签: java file command-line-arguments

我有一个位于

的程序

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

$ A430CLASS是我的班级文件所在的路径。

我想通过shell脚本运行它,所以我输入了以下命令:

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

$ A430CONF是batch.properties文件所在的路径。 GlobalReportBatch是我的类文件名 正如您所看到的,我想将此batch.properties文件作为参数传递给我的java程序。但是当我运行我的脚本时,它会尝试替换“。”在batch.props文件中,“/”它给我NoClassDefFound错误。

1 个答案:

答案 0 :(得分:4)

-classpath选项之后放置的内容必须是目录和JAR文件的列表,由:(在类Unix操作系统上)或;(在Windows上)分隔。

看看你传递的是什么:

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

删除/与您的班级名称之间的斜杠$A430CLASS;用空格替换它:

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

所以整行都变成了:

java -classpath $A430CLASS com.airbus.adcsip.batch.GlobalReportBatch $A430CONF/batch.properties
相关问题