Code Monkey home page Code Monkey logo

urischemehandler's Introduction

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:[email protected]
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>1.7</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. Limitations

OS X is not implemented yet. If this library is called from a mac os it throws a exception.

urischemehandler's People

Contributors

beothorn avatar lionel1704 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.