Why does Java’s URL class not recognize certain protocols?

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 how 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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)