I am currently invoking the following line of code:
java.net.URL connection_url = new java.net.URL("http://<ip address>:<port>/path");
and I get the exception above when it is executed. Any ideas as to why this is happening?
Your code works fine for me:
public static void main(String[] args) { try { java.net.URL connection_url = new java.net.URL("http://:/path"); System.out.println("Instantiated new URL: " + connection_url); } catch (MalformedURLException e) { e.printStackTrace(); } }
New URL created: http: //: / path
Do you have the correct line of code?
As a side note, you should use URIs because the Java URL class is confusing. (I assume the method is equal)
url . , http://path '? ?
I also had the same exception, but in my case, the URL that I was trying to execute took place. After removing the space, it worked perfectly for me. Make sure your URL does not have trailing spaces.
I had the same error and it was solved as follows:
The jar (JFree) files that I added a few days ago were corrupted automatically and caused this error. I downloaded the same files from the network again, and it worked fine for me.