JAVA类路径传递文件作为命令行参数 [英] JAVA classpath pass file as command line argument

查看:121
本文介绍了JAVA类路径传递文件作为命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位于

say

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

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

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

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是存在batch.properties文件的路径。
GlobalReportBatch是我的类文件名

如您所见,我想将此batch.properties文件作为参数传递给我的Java程序。但是当我运行我的脚本时,它将尝试替换。将batch.props文件中的文件添加到 /,这会给我 NoClassDefFound 错误。

推荐答案

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

What you put after the -classpath option must be a list of directories and JAR files, separated by : (on Unix-like operating systems) or ; (on Windows).

看看您要传递的内容:

Look at what you are passing:

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

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

Remove the slash / between $A430CLASS and your class name; replace it by a space:

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

因此整行变为:

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

这篇关于JAVA类路径传递文件作为命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆