Java - Creating a new file extension in a program

狂风中的少年 提交于 2019-11-29 19:06:51

问题


I'm aiming to create a new file extension (possibly more than one) for a program I'm creating. So, after looking around for a bit, I found a number of sources on the subject, listed below, just in case anyone wants to look at them and get the general idea of what I have been looking at.

Utilising a file association in a Java application

Create registry entry to associate file extension with application in C++

Associating file extensions with a program

http://support.microsoft.com/?scid=kb%3Ben-us%3B185453&x=6&y=11

http://www.rgagnon.com/javadetails/java-0592.html

http://www.rgagnon.com/javadetails/java-0480.html

Also, note that the Microsoft support one is actually a Visual Basic lesson, but I was just trying to see if there were any similarities in the registry changing.

Most of them generally talk about doing some registry editing so that Windows can recognize the new file and know what to do with it. Then I stumbled upon this document by Oracle, which claims that you are able to do all of the above with some (seemingly) simple Java code. I figure if it's that easy, though, somebody would have pointed it out already. Also, that document is from 2006. I've got a number of questions, which I understand can be a lot to go through, so if anyone takes time out to answer this, thanks a bunch!

  • What's really the best way to go about creating and associating a file type for a Java program?
  • If the Oracle method is used, is it done in a completely separate program? I would assume you don't want the file type being created and associated every time the program runs, and from what I've seen, that will actually return errors.
  • I want other people (only Windows users) to be able to easily install the program, but I'm on Windows 7 64-bit. Are there any changes I should be aware of to make the association also compatible with 32-bit systems?
  • Are the changes easily and completely reversible with either method (i.e. if I just wanted to create a test file extension)?

I couldn't find any extensive sources on teaching how to do this kind of stuff with no previous knowledge of it, so if anyone can't answer my questions, but does have a good source I can look at, that would be nice, too.


回答1:


Java Web Start is not only a freely available installer that comes from Oracle, but it will also register an apps. interest in file types. See the File service demo. for an example.



来源:https://stackoverflow.com/questions/7361881/java-creating-a-new-file-extension-in-a-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!