Using Registry with JAVA in Mac OS

2019-05-24 03:25发布

问题:

I have written a Java desktop application in Windows platform that is using the Windows Registry to save the application information like location of the application, time-period (like free-trial up to 30 days ) etc.

Now, i want to create the same java application to run on Mac OS. Although the most of the java code will be same but i am not sure about the Registry concept in Mac OS. Is there any Registry in Mac Os like in Windows platform. If yes, how can i use the Mac Registry with JAVA to write application information?

Regards,

Arun Kumar

回答1:

The java.util.prefs mechanism is the cross-platform way to approach this sort of thing. On Windows it's backed by the registry, on Mac it's backed by .plist files in ~/Library, and on Linux and friends it's backed by files in ~/.java, but the API you use to access the information is the same on all platforms.