views:

167

answers:

4

Hello all ,

URL u=new URL("telnet://route-server.exodus.net");

This line is generating :

java.net.MalformedURLException: unknown protocol: telnet

And i encounter similar problems with other URLs that begin with "news://"

These are URLs extracted from ODP , so i dont understand why such exceptions arise..

+4  A: 

Issue

Java throws a MalformedURLException because it couldn't find a URLStreamHandler for that protocol. Check the javadocs of the constructors for the details.

Summary:

Since the URL class has an openConnection method, the URL class checks to make sure that Java knows now to open a connection of the correct protocol. Without a URLStreamHandler for that protocol, Java refuses to create a URL to save you from failure when you try to call openConnection.

Solution

You should probably be using the URI class if you don't plan on opening a connection of those protocols in Java.

Ben S
A: 

Sounds like there's no registered handler for the protocol "telnet" in your application. Since the URL class can be used to open a InputStream to URL it needs to have a registered handler for the protocol to do this work if you're to be allowed to create an object using it.

For details on how to add handlers see: http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLStreamHandlerFactory.html

Ian C.
A: 

you're getting that error because java doesn't have a standard protocol handler for telnet.

Also a discussion here on providing protocol handlers

objects
A: 

The simple answer is that it only does recognize certain protocols, and the remainder of the infinity of protocol is not recognized.

EJP