Java - Launch html Document

Discussion in 'Mac Programming' started by VegetaPunk, Feb 3, 2006.

  1. macrumors 6502

    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?
  2. Moderator


    Staff Member

    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.
  3. macrumors 6502

    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.
  4. macrumors 603


    This piece of code looks very promising. (The web designer's sense of usability/readability isn't quite as promising.)
  5. macrumors 6502

    Depending on the complexity of the HTML you're looking to display I'd recommend looking at Java's JEditorPane.
  6. macrumors 6502a


    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.
  7. macrumors 6502

    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!
  8. macrumors 6502

    =( it didnt work with windows is there another path I need to use besides "/usr/bin/open" ?

    thanks in advance
  9. macrumors 6502

    "cmd /c" worked for me (using win2k) =)

Share This Page