Registering a URL protocol handler in a multiple platforms

Viewed 8620

I an wanting to create a Java application that is installed on multiple platforms (Windows,Mac OS, Linux) as a part of this install I wish to register a URL protocol handler, so that my app loads when links are clicked.

i.e. I want something like this: myprotocol://example.com

Is there any sort of consolidated way of doing this? Or some sort of framework that extrapolates the difference across the different OS's.

6 Answers

As an alternative, using the JDIC project you can associate files with specific applications.

This may be useful for your proposes. But instead of registering the whole protocol ( which may be somehow complicated ) you may register the file type only.

So, a link like this:

 <a href="http://example.com/file.dan">Dan File</a>

May be opened with your application.

Here's the sample code to register your app to open that file type:

AssociationService serv = new AssociationService();
Association logassoc = new Association();

logassoc.addFileExtension("DAN"); 
logassoc.addAction( new Action("open", "C:\\WINDOWS\\JAVA.EXE -jar C:\\dan.jar %1"));

Here's the complete article: Understanding JDIC File-Type Associations

I would recommend that you use Java Webstart rather than try to invent a new link scheme. It's already supported by any browser that has Sun Java installed.

Related