Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Viewing a file using default application associated with it  RSS feed

 
Rahul Agarwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to make an application in which a box appears and from where I can select a file which will open in default application associated with it.
Like .pdf files should open in Acrobat Reader and .htm in explorer and .doc in Word.
Can somebody help?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Windows, when the user tries to open a file, Windows searches the registry for a known file extention. If it finds one, it reads the registry entry to find out which application is to be used for that type of file. Then it opens the file using that app. If no matching entry can be found in the registry you will get the little dialog box telling you that the file type is unknown. It asks you to pick an application to use for opening this file. To duplicate this functionality in Java, you will have to use JNI to access the system registry.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!