Tom
Tom

Reputation: 23

Launching a java application from an URI

I'm looking for a way to launch my java application when using a custom URI. Something in the lines of movie://superman/

This should start my application and display information about the movie "Superman".

if friends of my have my application installed as well, i can send them that URI so they can click on it.

I used to do this back in the days in VB6 but i lost my code and forgot how to do it.

OS: windows

Any help would be appreciated.

Upvotes: 2

Views: 551

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168835

..should start my application and display information about the movie "Superman".

If you can distribute your app. from a web site, you might take a slightly different approach:

  1. Launch the app. using Java Web Start.
  2. In the JWS launch file (JNLP format), add a custom file extension, e.g. xuri.
  3. Send the user an clickthis.xuri file containing the URI of interest.
  4. When the JWS app. registered to that file type is invoked, it will be passed -open clickthis.xuri as arguments to the main(String[]).
  5. Proceed from there..

This approach should work on any OS with 'modern' Java installed. JWS was available since 1.2, & became co-bundled with the JRE around 1.4.2.

Upvotes: 0

Joachim Sauer
Joachim Sauer

Reputation: 308131

The actual mechanism to implement this is operating-system dependent (and thus not accessible from pure Java).

The general idea is to register your application as the protocol handler for the protocol in question.

On Windows you do that by writing the appropriate registry keys

Upvotes: 6

Related Questions