简体   繁体   中英

Java shared Property File: Windows + Unix (generic)

So, in my departement, we got an Java application (running on Unix) which can be parametrised by an .property File. Inside this File, there are few refrences to other files (eg Log file path). Now, we need to use the same application on windows platforms. Everything works fine, until it should all be generic. So, we don't want to change anything except the .property file to make it run on both systems generic. But I don't really know how to handle this. On Unix, I need like environment variavles on unix but I know, Java can not resolve environment variables automatically. In windows its like the same. How would you solve this problem?

Add a property for each OS and then read accordingly on code

# properties file
my.prop.nix=/some/unix/path
my.prop.win=c:\some \window$\path

Read OS on java with

String OS = System.getProperty("os.name").toLowerCase();

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