I making an app in Java. I want an Open With Dialog to appear when a JButton
is clicked.
I know that in Windows, the contents of the Recommended Programs list are determined from the registry entry
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\filetype\OpenWithList
..where 'filetype' is the required file type.
Is there any way that this can be done with complete independence of the OS in which this app runs? Or do I have to get the OS name and program accordingly?
Not completely sure whether this answer will be relevant as I am making some assumptions. In case it is a file you want to open, you can use Desktop#open
which will open the File
with the default application.
I assume (but did not test) that when no default application is set, a dialog will be shown asking what application you want to use to open that file (similar as when you double click such a file in your file browser).
This is not completely what you asked for, but might be sufficient.
Otherwise I am afraid I agree with Andrew's answer that there is no general way to do this.