Eclipse: How to prompt user to choose an application to open a file with?
eclipse, eclipse-plugin, java
Solution
Any solution I can think of would depend on the OS. For example if your application is running in windows you could provide the user with a list of all *.exe files in the Program Files folder. Or all applications in the /bin, /sbin, /usr/bin, /usr/share/bin for a linux OS.
Problem
I want to open arbitrary files from Eclipse. Currently I'm doing it like that: ``` if (((File) selectedElement).isFile()) { try { Desktop.getDesktop().open((File) selectedElement); } catch (IOException e) { //TODO prompt for the appropriate application to open this file. e.printStackTrace(); } } ``` Unfortunately, this only works, if the OS has a default application associated with the file type. That's why, if there isn't any default application defined, I want to ask the user which application I should use. But I have no idea how to 1) find a list of available application and 2) open the file with that application. Any hints how to implement that in a platform-independent way?