简体   繁体   中英

passing environment variable to a java class in command line

I have a necessity to read some properties from a file located in local etc/myconfig-config/ folder. I need to give this file path in the command line. I have given it as mentioned below. But there is an error and it displays like

Error: Could not find or load main class test-tool.jar. 

the command given is

java  -cp -DconfigDir=/etc/myconfig-config/ test-tool.jar 
service.ScriptGenerator $clinic_count $client_files_count 

can anybody please help me to resolve this.

thanks

尝试给出以下命令,

java -DconfigDir=/etc/myconfig-config/ -cp test-tool.jar service.ScriptGenerator $clinic_count $client_files_count 

Try this command

export VARNAME='variable-value'

Then run your Java main class from the same command line.

你的命令应该是这样的

java  -cp test-tool.jar -DconfigDir=/etc/myconfig-config/ service.ScriptGenerator $clinic_count $client_files_count 

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