This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes opening default web browser in linux/unix/solaris/windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "opening default web browser in linux/unix/solaris/windows" Watch "opening default web browser in linux/unix/solaris/windows" New topic
Author

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

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 807
    
    1

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?


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4763
    
    6

The method does what the API says it does.


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19913
    
  23

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: opening default web browser in linux/unix/solaris/windows