11

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?

Sri Harsha Chilakapati
  • 11,744
  • 6
  • 50
  • 91
Frizinator
  • 1,351
  • 3
  • 12
  • 16

3 Answers3

2

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+

user11153
  • 8,536
  • 5
  • 47
  • 50
0

As user11153 wrote originally this seems to be related to the null character \0 (or some other unicode experiments I did recently... ). This happens for me with JShell 17.0.1 installed with the jdk that is built and deployed by the IntelliJ IDEA.

I experimented a little with the file that is saved in your home directory (for me in .java/.userPrefs/tool/JShell/IncorrectFormatPrefs.xml, but this should be similar in your case) until I found the offending line

<entry key="HISTORY_LINE_161" value="&quot;<ffff>&quot;.length()"/>

After I removed this line and renamed the file from IncorrectFormatPrefs.xml to prefs.xml the warning vanished.

Zin
  • 1
-1

I had same problem when running intellij idea in ubuntu 20.04.

First, I have inttelij in /opt directory then error happen when trying to start. "Pref file removed..."

Put inttelij in home directory and problem solved.