In developing PasswordSafeSWT, I’ve never really been able to get URL launching working successfully (“Go to Password Safe Website” type stuff) on all platforms. I’ve toyed with BrowserLauncher (which seems to work great on Win32 and Linux but causes my OSX box all sorts of grief).
Well, after checking out some of the SWT newsgroups, the answer is much simpler than I thought. You can launch arbitrary programs using the Program class, and they launch with whatever app is associated with them (ie whatever is the default browser on the platform). So I just dropped the following line into my Action, and I was in business:
org.eclipse.swt.program.Program.launch("http://passwordsafe.sourceforge.net/");
I’m a raving fan-boy. I just love SWT….
Thank you. I have been searching for days for this kind of stuff, in order to bring a Link widget in my SWT application to life.
All I could find was Runtime.exec(), which starts the default browser for html files (try cmd /c file.html from a windows command prompt), but didn’t work for actual links.
One more problem solved:) Thank you.
Ciprian
Glad I could help.
Love you man! Have been searching Google for something like this for like 20 minutes… gave up and started going thru my bookmarks instead (including your site) and here it is! Thanks!
Good stuff. Enjoy.
A fantastic tip – I was about to go down the BrowserLauncher route until I found this. Unfortunately though, it doesn’t seem to work for me under KDE on Linux. My default browser there is Konqueror, and typing http://www.google.com into the Run box loads it just fine. Sadly, calling Program.launch does nothing on this platform (it assumedly returns false but I haven’t checked yet). The same code works perfectly under Windows XP (where it launches Firefox).
thanks a ton man ..see u wrote something 2 years back and it helped me a great deal today..thanks a ton
wow! what you wrote 5 years ago helped me today!
Thanks!!
Hahaha… same, thanks Glen!
thanks!!
it was very helpful to me!