Linux – What program to use to open files? (gnome-open, gvfs-open, xdg-open, etc.)

file openinglinuxxdg-open

I have a Java program that runs on Linux, and from within the program, I want to open files (e.g. PDF files) with the system's native viewer. There are various programs available for this purpose: gnome-open, gvfs-open, xdg-open, …
Which one(s) should I use to cover as many Linux distributions as possible?

Best Answer

xdg-open is the safest bet. Not everyone will necessarily have gnome or gvfs installed. xdg-open, on the other hand, is not tied to any desktop environment or toolkit.

Related Question