2

I have created a Java application and created a Mac .app file from it to run simply on Mac OS X. The application can create special project files and save them with the extension *.ksdi so the user can easily run those project files again and edit them.

What I would like to do is allow the user who installed the application on his Mac to be able to double click those *.ksdi files to automatically run the program and automatically load the project file. How can I do that in Mac?

Can I assign an extension to my Mac program through a script or something like that so user won't have to assign the extension to the program manually?

Update: Trial solution:

I have read in another post that I should add a key to the *.plist file to accomplish this, so I added this to it:

<plist>
    <dict>
        <key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeRole</key>
                <string>Viewer</string>

                <key>LSIsAppleDefaultForType</key>
                <true/>

                <key>LSItemContentTypes</key>
                <array>
                    <string>public.ksdi</string>
                </array>
            </dict>
        </array>
    </dict>
</plist>

I saved the plist file, but I do not know how to activate this! I have run the application, restarted my mac, but still when double clicking any ksdi file it doesn't open it with the program... Any help?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Brad
  • 4,457
  • 10
  • 56
  • 93
  • See http://stackoverflow.com/questions/1575190/double-click-document-file-in-mac-os-x-to-open-java-application – Michael Brewer-Davis Oct 31 '11 at 21:33
  • possible duplicate of [How to associate file type with MacOS X App without launching it first?](http://stackoverflow.com/questions/435175/how-to-associate-file-type-with-macos-x-app-without-launching-it-first) – Matt Ball Oct 31 '11 at 21:41
  • Thanks guys, but those questions have no clear answers. Should i add a property to the *.plist file to accomplish this or what ? – Brad Nov 01 '11 at 13:28
  • 1
    Possible duplicate of [How to associate file type with MacOS X App without launching it first?](http://stackoverflow.com/questions/435175/how-to-associate-file-type-with-macos-x-app-without-launching-it-first) – David Heffernan Jan 11 '17 at 20:36

2 Answers2

2

I do this using Install4J, they make it really easy.

(btw, I have no affiliation with Install4j or the company).

Jonathan
  • 1,327
  • 3
  • 15
  • 24
1

As per one of the "exact duplicate" questions.

Application Registration

All applications available on the user’s system must be registered to make them known to Launch Services and copy their document binding and other information into its database. It isn’t ordinarily necessary to perform this task explicitly, since a variety of utilities and services built into the Mac OS X system software take care of it automatically:

A built-in background tool, run whenever the system is booted or a new user logs in, automatically searches the Applications folders in the system, network, local, and user domains and registers any new applications it finds there. (This operation is analogous to “rebuilding the desktop” in earlier versions of Mac OS.) The Finder automatically registers all applications as it becomes aware of them, such as when they are dragged onto the user’s disk or when the user navigates to a folder containing them. When the user attempts to open a document for which no preferred application can be found in the Launch Services database, the Finder presents a dialog asking the user to select an application with which to open the document. It then registers that application before launching it.

In spite of these automatic registration utilities, it may sometimes be necessary to register an application explicitly with Launch Services. For example, although developers are encouraged to package their applications so that they can be installed by simply dragging them onto the user’s disk, some applications may require more elaborate custom installer software. In such cases, the installer should call one of the Launch Services registration functions LSRegisterFSRef or LSRegisterURL to register the application explicitly.

Community
  • 1
  • 1
  • How can i register my application as mentioned in 1st line ? I don't want to use an installer, so can i register my application + Use the plist keys specified in my question, and things will work fine ? – Brad Nov 01 '11 at 20:27
  • read for comprehension ALL the instructions in the **link** provided in my answer –  Nov 01 '11 at 20:30