5

I have some Java programs that write some files to the desktop, read them, check them, and delete them. This might happen to about 50 files. Sometimes a few files remain on the desktop. The ones that remain seem random. I used to try to delete them but I resented doing that. I don't remember if deleting actually works but today I find that I can't delete the file. I discovered that after rebooting the files are gone.

Why is this happening?

There is a padlock icon on top of the icon of the file itself. The same program invocation can also result in no padlock icon on top of the file icon. If I right click the file icon in order to "move to trash" there is a dialog that says

“Test Range.txt” can't be put in the trash. Do you want to delete it immediately?

If I choose to delete it immediately it says

Error while deleting. Error when getting information for file '/home/jack/Desktop/Test Range.txt': No such file or directory

If I do ls -la the file is not present even though it is visible on the desktop.

I'm using Java 8 update 112 but I think this problem has been around since earlier versions of Java. I'm also using Ubuntu 16.04.

Addendum: In response to a request for more information I was asked to issue the command:

apt-cache policy nautilus nautilus-data

That command results in:

    nautilus:
  Installed: 1:3.18.4.is.3.14.3-0ubuntu5
  Candidate: 1:3.18.4.is.3.14.3-0ubuntu5
  Version table:
 *** 1:3.18.4.is.3.14.3-0ubuntu5 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1:3.18.4.is.3.14.3-0ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
nautilus-data:
  Installed: 1:3.18.4.is.3.14.3-0ubuntu5
  Candidate: 1:3.18.4.is.3.14.3-0ubuntu5
  Version table:
 *** 1:3.18.4.is.3.14.3-0ubuntu5 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
        100 /var/lib/dpkg/status
     1:3.18.4.is.3.14.3-0ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu xenial/main i386 Packages
H2ONaCl
  • 9,693
  • 1
    It seems something related to nautilus (file-manage) . Could you add the output of apt-cache policy nautilus nautilus-data . You can also force to update desktop by restarting it, sudo killall nautilus; nautilus -n & disown – user.dz Dec 18 '16 at 01:07
  • Try reseting its settings dconf reset -f /org/gnome/nautilus/ then sudo killall nautilus; nautilus -n & disown – user.dz Dec 20 '16 at 13:59
  • It seems that your Java program is successfully deleting the files. It appears that the GUI is not loading that the file is gone. If you get the error saying "No such file or directory" and using ls -la doesn't show anything, your files are already gone. I would try asking (or editing your question) a question involving the GUI. Good luck! – James Dec 20 '16 at 17:44

4 Answers4

4

Instead of a reboot, you can refresh the Desktop by pressing F5 to get rid of the phantom icons.

It is documented here in this askubuntu.com answer. I could not find a more canonical reference.

H2ONaCl
  • 9,693
3

A reboot or a logout is not necessary.

In terminal type nautilus -q. Then quit terminal. Then click the Files icon in the launcher to bring back Nautilus... and your mysterious desktop icons should be gone.

heynnema
  • 70,711
  • This sort of works but I had to hold down the soft power button (on this Dell server) for about 1 second to revive the computer. Otherwise it appears to be an infinite loop. – H2ONaCl Dec 18 '16 at 01:57
  • Do you have ubuntu-desktop installed on this server? I didn't notice that you said this was a server before. How do you have a "desktop"? Can you put your work files in /tmp instead of the "desktop"? – heynnema Dec 18 '16 at 02:11
  • I installed the regular desktop version of Ubuntu on this server. The reason I put files in ~/Desktop instead of /tmp is because I need convenient visibility. – H2ONaCl Dec 18 '16 at 02:46
  • I'd try this another time and see if you get the same result. – heynnema Dec 21 '16 at 21:04
3

This problem is not related to Java. Instead, it can probably be blamed on desktop caching. Namely, the files themselves were actually deleted, but the file manager (for whatever reason) did not respond to the fact that the files vanished, and keeps your "ghost" icon around.

You can fix this by killing Nautilus through killall nautilus, which will end all active Nautilus processes (including the desktop), clearing Nautilus' caches. Then, simply run Nautilus again from the menu or Dash, and your desktop would be reset. Sometimes, just hitting the F5 key while on your desktop can also refresh and clear any icon caches.

Alternatively, you can reboot or relog your graphical session.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
1

A reboot is not necessary. To quickly get rid of the deleted file icons that are still visible on your desktop, logout and then login again.

karel
  • 114,770
  • A GUI logout and GUI login works to get rid of the desktop icon remnants but it has the side effect of closing open applications like Firefox and the Terminal. I no longer remember how to do non-ssh CLI logout and CLI login. – H2ONaCl Dec 18 '16 at 01:46