• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the program associated with a file's extension

 
testa lucida
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
finally I succeeded in placing a file's symbol and name into a JTextPane.
Now I want the associated program to start when doubleclicking the icon (e.g. WORD, when a .doc file is dblclicked).
How can I retrieve the appropriate program? Do I have to search the registry?

Thanks in advance
Regards
testalucida
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String fileName = [obtained from icon click];
Runtime.getRuntime( ).exec("rundll32 url.dll,FileProtocolHandler "+fileName);

if the file is not in the same directory as the application, fileName has to include the path
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!