在命令行中将环境变量传递给 java 类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30889478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:47:44  来源:igfitidea点击:

passing environment variable to a java class in command line

java

提问by Dilan

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

我有必要从位于本地etc/myconfig-config/文件夹中的文件中读取一些属性。我需要在命令行中给出这个文件路径。我已经给了它,如下所述。但是有一个错误,它显示为

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

谢谢

回答by Sathish

Try giving following command,

尝试给出以下命令,

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

回答by Aakash

Your command should be like

你的命令应该是这样的

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