开发者

Launching a java application from an URI

开发者 https://www.devze.com 2023-03-02 04:01 出处:网络
I\'m looking for a way to launch my java application when using a custom URI. Something in the lines of

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 app开发者_StackOverflow社区reciated.


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


..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.

0

精彩评论

暂无评论...
验证码 换一张
取 消