This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
i want to know is linux have registry. Because i have an application in java. I want to write some data to registry from that application. In windows its working fine i don't know is this will work with Linux or i need to modify the code to work in linux.
Linux systems generally do not have a registry in the same way that Windows has.
What information do you need to read or write? On Unix-like systems, applications usually write configuration files to the user's home directory, using a filename that starts with a . (dot), which makes the files hidden.
Originally posted by Ulf Dittmer: Check out the Preferences API (in java.util.prefs). It saves application settings and the like in a way that's appropriate for the host OS (which on Windows is the Registry).
Then if i run my application in linux it will take care of saving registry entry in Linux am i right
Joined: Mar 22, 2005
It will save the setting, yes. How it does it depends on the JVM implementation. The Registry in particular is a Windows-only thing. [ July 18, 2008: Message edited by: Ulf Dittmer ]
Originally posted by Chiru Raj: But i need to take care of Accidental deletion of that file but in windows its safe if it is in the Registry
Yes, and when the hard drive fails, you either have to restore the registry from a backup - which can fail if the new drive configuration doesn't match OR you have to recreate the entire registry from scratch, which means finding all the application install disks, re-installing each and every one of the apps, adding the app updates and service packs, and generally spending about a week just to get basic system functionality back. Oh wait, I'm showing my age. Nowadays you also have to make the reinstalled apps phone home and register with the software vendor.
Or to say it another way - in Linux, if you delete a file, you lose the file. In Windows, if you corrupt the registry, you've lost the entire registry!
The registry was a good idea, and it served a very useful purpose back when FAT sector sized were very large and config files were very small. However, things have changed a lot, and the downsides of the registry have become apparent. Not only do you put all your eggs in one basket - that basket has a proprietary binary format. Linux/Unix config files are normally text files. They can be backed up and restored using ordinary archive utilities and they can be scanned and/or modified in bulk using ordinary text utilities.
I do, in fact, back up my /etc directory tree on a daily basis using a cron-scheduled tar job.
Back in the Windows world, some developers have gotten fed up with registry headaches and gone back to ini files. The registry has one advantage over ini - which is that you can build a hierarchy instead of just a flat option tree, but these days so do XML config files.
Customer surveys are for companies who didn't pay proper attention to begin with.