简体   繁体   中英

how to set properties file path in shell script

如何使用以下命令在运行主类的shell脚本中设置Properties文件的路径以及Java命令:

java -cp %classpath% -Doligosoft.POSConfig.file="/home/mlpc04/Paritosh/Workspace/POS_3.0 resources/posconfig.properties"com.floreantpos.main.Main

You could change your classpath with a new one, which owns the properties file. If your properties file is in the root of your classpath it could be used from your Java program using something like this:

Someclass.class.getResourceAsStream(posconfig.properties)

For example your new classpath could be something like this:

OLDCLASSPATH:/home/mlpc04/Paritosh/Workspace/POS_3.0 resources/

By the way: you said you are using a shell script. I do not know what kind of shell you are using but %classpath% sounds like a DOS SCRIPT (Windows) and your path looks like a Linux one where I doubt you are going to use a DOS SCRIPT.

This depends on how the program you are using expect the properties file to be communicated to it.

It could be in the classpath directly.

Or it could be done via a command line argument like you shown in your question Have a look at https://stackoverflow.com/a/3457999/592898

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