Java - Launch html Document

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

  1. macrumors 6502

    Joined:
    Dec 30, 2002
    Location:
    AZ
    #1
    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 emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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

    Joined:
    Sep 4, 2001
    Location:
    West Sussex, UK
    #3
    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

    gekko513

    Joined:
    Oct 16, 2003
    #4
    This piece of code looks very promising. (The web designer's sense of usability/readability isn't quite as promising.)
     
  5. macrumors 6502

    Joined:
    May 17, 2002
    Location:
    Denver, CO
    #5
    Depending on the complexity of the HTML you're looking to display I'd recommend looking at Java's JEditorPane.
     
  6. macrumors 6502a

    jalagl

    Joined:
    Jun 5, 2003
    Location:
    Costa Rica
    #6
    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. thread starter macrumors 6502

    Joined:
    Dec 30, 2002
    Location:
    AZ
    #7
    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. thread starter macrumors 6502

    Joined:
    Dec 30, 2002
    Location:
    AZ
    #8
    =( it didnt work with windows is there another path I need to use besides "/usr/bin/open" ?

    thanks in advance
     
  9. thread starter macrumors 6502

    Joined:
    Dec 30, 2002
    Location:
    AZ

Share This Page