Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 813
Frizinator Avatar asked Oct 13 '12 01:10

Frizinator


1 Answers

Probably you are affected 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

Solution: update to Java 9+

like image 74
user11153 Avatar answered Nov 15 '22 12:11

user11153