I mean, how does Java decide which protocols are available? I run some code from inside Eclipse, and it works just fine. Then I run the same code from outside Eclipse, and I get "unknown protocol" MalformedURLException. Probably it has to do with the code base, or something? Any hints would be helpful.
Thanks!
The work of resolving the protocol is done by the URLStreamHandler
, which are stored in URL.handlers
by protocol in lowercase. The handler, in turn, is created by the URLStreamHandlerFactory
at URL.factory
. Maybe eclipse is monkeying with that?
Some of the URL constructors take stream handlers and you can set the factory with URL.setURLStreamHandlerFactory.
Here's a web post about developing protocol handlers.