Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

VegetaPunk

macrumors 6502
Original poster
Dec 30, 2002
322
0
AZ
Im using JBuilder to make a java application.
In this application I want to add a help button that when you press it launches a help.html document, that I have made, using the systems defualt browser. How do I launch a document in java?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I don't think it's possible in pure java as the method for doing that will be OS dependant. On OSX you would do it via NSWorkspace using the openURL method. You will need to look at other solutions for other platforms.
 

iJed

macrumors 6502
Sep 4, 2001
264
10
West Sussex, UK
VegetaPunk said:
Im using JBuilder to make a java application.
In this application I want to add a help button that when you press it launches a help.html document, that I have made, using the systems defualt browser. How do I launch a document in java?

I believe you could use Runtime.exec("/usr/bin/open " + filePath).

You may not need to use the open command but I'm not sure as I've never tried this before. Also remember that open is Mac OS X specific so it will not be a good cross platform solution.
 

gekko513

macrumors 603
Oct 16, 2003
6,301
1
VegetaPunk said:
Im using JBuilder to make a java application.
In this application I want to add a help button that when you press it launches a help.html document, that I have made, using the systems defualt browser. How do I launch a document in java?
This piece of code looks very promising. (The web designer's sense of usability/readability isn't quite as promising.)
 

jalagl

macrumors 6502a
Jun 5, 2003
802
1
Costa Rica
iJed said:
I believe you could use Runtime.exec("/usr/bin/open " + filePath).

You may not need to use the open command but I'm not sure as I've never tried this before. Also remember that open is Mac OS X specific so it will not be a good cross platform solution.

I've used this before on Windows, and it launches the default browser (it is the same functionality as if you double-clicked the html file.
 

VegetaPunk

macrumors 6502
Original poster
Dec 30, 2002
322
0
AZ
TY for all the help guys!
I used the runtime and it works on the mac now I just need to test it on my pc! thanks again!
 

VegetaPunk

macrumors 6502
Original poster
Dec 30, 2002
322
0
AZ
=( it didnt work with windows is there another path I need to use besides "/usr/bin/open" ?

thanks in advance
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.