How do I fix a "Prefs file removed in background /home/steven/.java/.userPrefs/prefs.xml" error?

Frizinator picture Frizinator · Oct 13, 2012 · Viewed 8.2k times · Source

I've been programming on Windows for the majority of my program with no problems with preferences. I just booted up Ubuntu 12.04 and loaded up my classes into Eclipse. At run time, I receive this in the console:

Oct 12, 2012 8:14:38 PM java.util.prefs.FileSystemPreferences$6 run
WARNING: Prefs file removed in background /home/steven/.java/.userPrefs/prefs.xml

I understand this has something to do with the preferences system on Ubuntu but several Google searches resulted in no solutions. Could anyone help me on how do I fix such an error?

Answer

user11153 picture user11153 · Sep 17, 2015

Maybe you are afected by this bug: https://bugs.openjdk.java.net/browse/JDK-8068373

(prefs) FileSystemPreferences writes \0 to XML storage, causing loss of all preferences

If you call prefs.put(key, "some string with \0 in it") ...

The XML writer happily writes the \0 into the file. I think it escapes it, but as already mentioned, this is pointless. Then later, when you try to read it back in, the XML file is invalid. You get a warning on the logs about the preferences file being invalid and all your preferences are wiped.

ADDITIONAL OS VERSION INFORMATION:

Occurs on all flavours of Linux we have tested. Issue is also reproducible on any platform if you deliberately use this PreferencesFactory.

You also get the following output on stderr:

Dec 29, 2014 9:19:19 AM java.util.prefs.FileSystemPreferences$6 run 
WARNING: Invalid preferences format in /Users/daniel/.java/.userPrefs/com/acme/testing/prefs.xml 
Dec 29, 2014 9:19:19 AM java.util.prefs.FileSystemPreferences$6 run 
WARNING: Prefs file removed in background /Users/daniel/.java/.userPrefs/com/acme/testing/prefs.xml