2

Anybody knows how to handle custom URL schemes with Java? Like when you access any itms:// URL in browser, iTunes will handle it.

I know it's possible by writing native code applications that calls my Java code, but I don't know if it's possible with Java only.

I'll probably use some AWT code and I need it to be called by the browser.

Thanks!

1
  • This probably isn't done with Java but with operating-system specific APIs. You need to register your app as a handler for your URL scheme with the OS during installation. Commented Jan 27, 2012 at 23:24

1 Answer 1

1

The nearest way to launch something would be via http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html but that either does an open(File f) or browse(URI). Maybe browse indirectly works for your purpose.

The next approach would be to extend URL's protocols by a Handler for a new protocol (like itms:). Do a web search for java protocol Handler as it relies on fixed class and package names, and an explanation here by me would be of poor quality. Then you could pass the URL to local code. This allows you to use these new URLs with java.net.URL.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your answer, Joop Eggen. I think my question wasn't so clear, my english is not so good. I want the opposite of what you said. I want my AWT code to be executed when the user access the custom scheme via browser.
I need Windows and Mac. I know how to do that with native code on both, and then call my Java code. But don't know if it's possible to call Java directly.
Sorry for misreading your question. On second read understood. stackoverflow.com/questions/2767569/… maybe helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.