abhilash-ram
abhilash-ram

Reputation: 93

java program to use url specified in the mail

I am having a java coding in which i need to open a webpage.that webpage link is available in my mail id.i had programmed to get my mail message to get the webpage link.now that webpage link is stored in a string URL.after that i had included

java.awt.Desktop.getDesktop().browse(java.net.URI.create(URL));

after that program should be closed.but when i run the program .i cant get the webpage opened. it shows

Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in path at index 0: "www.google.com"
    at java.net.URI.create(URI.java:859)
    at Email.main(Email.java:53)
Caused by: java.net.URISyntaxException: Illegal character in path at index 0: "www.google.com"
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.checkChars(URI.java:3002)
    at java.net.URI$Parser.parseHierarchical(URI.java:3086)
    at java.net.URI$Parser.parse(URI.java:3044)
    at java.net.URI.<init>(URI.java:595)
    at java.net.URI.create(URI.java:857)

Upvotes: 1

Views: 164

Answers (1)

Qwerky
Qwerky

Reputation: 18425

Have a look at the javadoc for URI. The URI is expected to be in a certain format, with a scheme. You are missing the scheme.

Upvotes: 1

Related Questions