The Info.plist
of our Java-based application contains following entries:
With Java 9, this is easy quite easy, and no longer requires Apple's EAWT classes or any ObjC hackery.
Desktop.getDesktop().setOpenURIHandler((event) -> {
System.out.println("Open URI: " + event.getURI());
// do something with the URI
});
The application needs to be bundled, and the CFBundleURLTypes key must be set.
CFBundleURLTypes
CFBundleURLSchemes
example
CFBundleURLName
Unfortunately this only captures the URI if the application is already running. If the application was launched by opening a URI, the event is not delivered (see comments on ed22's answer).