Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

opening default web browser in linux/unix/solaris/windows  RSS feed

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I do it using this method?

String url = "http://www.google.com";
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));

Is this method universal for different operating systems?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method does what the API says it does.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you should perform some checking first to prevent an UnsupportedOperationException to be thrown by either Desktop.getDesktop() or Desktop.browse:
If either check fails you will have to do something else.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!