简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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