aspose file tools*
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 Soft Skills this week in the Jobs Discussion 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: 804
    
    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: 4664
    
    5

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: 19783
    
  20

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