3

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 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for you reply. I have goggled .plist files are the Mac version of preference files. Similar to .ini files on Windows. So in actual they are the Property list files for a software application. Are .plist files are really the alternative of Windows Registry in Mac-OS?
They are a standard format that native mac applications use to store preferences. But the point is that you don't need to know or care about that, just use the Java Preferences API and it will store the data in whatever way makes most sense on the platform. You don't need any specific code for Windows, Mac, etc.
There is no single central "registry" as such on Mac but the plist files in ~/Library/Preferences do the same job. Each application has its own plist file and the format can represent an arbitrarily deep tree structure of data using nested "dictionaries" (sets of key/value pairs where the value can be, among other things, another dictionary).
One more thing Ian, Could you please suggest any tutorial or sample of Java Preferences API that is writing/reading to/from PLIST files in Mac-Os?
Any tutorial will do, the whole point of the preferences API is that you use the same Java code regardless of which platform you're running on. You could try this one from Oracle for starters.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.