Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
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: 5126
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
Pie
Posts: 20529
54
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