Skip to content

A Java library to add and use URI scheme handlers registered with the OS.

Notifications You must be signed in to change notification settings

beothorn/URISchemeHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

URISchemeHandler

A simple java library that calls system commands to open and register applications with an URIScheme. See http://en.wikipedia.org/wiki/URI_scheme

Browsers use the URI Schemes handlers registered with the OS to decide which application to use to handle a URI scheme. For example the mailto scheme name is usually associated with your default email client, so if there is something like this on a website:
mailto:foo@bar.com
It will open your email client when you click on it.

To use just add to your pom

<dependency>
	<groupId>com.github.beothorn</groupId>  
	<artifactId>URISchemeHandler</artifactId>
	<version>2.0.0</version>  
</dependency>  

Usage

Opening an URIScheme string with default handler:

String magnetLink = "magnet:?xt=urn:foobarbaz";  
URI magnetLinkUri = new URI(magnetLink);  
URISchemeHandler uriSchemeHandler = new URISchemeHandler();  
uriSchemeHandler.open(magnetLinkUri);

This will open the torrent client registered with the os to handle the magnet scheme name. For example, if you install utorrent, utorrent will open and ask you if you want to add the magnet link to your downloads.

Registering a URIScheme

URISchemeHandler urlHandler = new URISchemeHandler();  
String schemeName = "mySchemeHandler";  
urlHandler.register(schemeName,"c:\\mySchemeHandler.exe");  //c:\\mySchemeHandler.exe or any command to receive the URI as parameter

Before adding a new scheme, make sure it doesn't conflict with an existing one. There's a list of them on the wikipedia article mentioned above.

What's new on version 2.0.0

  • No need for admin user for windows
  • Added support for mac

Thanks @lionel1704 @dmmop

About

A Java library to add and use URI scheme handlers registered with the OS.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages