JAVA classpath pass file as command line argument

2019-08-25 01:33发布

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.

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. GlobalReportBatch is my class file name As you can see i want to pass this batch.properties file as argument to my java program. but when i run my script it tries to replace "." in batch.props file to "/" it gives me NoClassDefFound error.

1条回答
手持菜刀,她持情操
2楼-- · 2019-08-25 01:33

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

Remove the slash / between $A430CLASS and your class name; 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
查看更多
登录 后发表回答