Open html document

what can i do so that i can using java application to make browser open a html document
thank you for your help

public class BrowserControl
public static void displayURL(String url)
boolean windows = isWindowsPlatform();
String cmd = null;
try
if (windows)
                    try
                         Runtime.getRuntime().exec("start iexplore \""+url+"\"");
                    catch (java.io.IOException e)
                         System.out.println("caught ioexception") ;          
                         //e.printStackTrace();
                         try
                              Runtime.getRuntime().exec("cmd /c start iexplore \""+url+"\"");
                         catch(Exception ee)
                              System.out.println("caught again ee") ;          
                              ee.printStackTrace();
                              // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
                              cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
                              Process p = Runtime.getRuntime().exec(cmd);
else
// Under Unix, Netscape has to be running for the "-remote"
// command to work. So, we try sending the command and
// check for an exit value. If the exit command is 0,
// it worked, otherwise we need to start the browser.
// cmd = 'netscape -remote openURL(http://www.javaworld.com)'
cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
Process p = Runtime.getRuntime().exec(cmd);
try
// wait for exit code -- if it's 0, command worked,
// otherwise we need to start the browser up.
int exitCode = p.waitFor();
if (exitCode != 0)
// Command failed, start up the browser
// cmd = 'netscape http://www.javaworld.com'
cmd = UNIX_PATH + " " + url;
p = Runtime.getRuntime().exec(cmd);
catch(InterruptedException x)
System.err.println("Error bringing up browser, cmd='" +
cmd + "'");
System.err.println("Caught: " + x);
catch(Exception x)
// couldn't exec browser
System.err.println("Could not invoke browser, command=" + cmd);
System.err.println("Caught: " + x);
* Try to determine whether this application is running under Windows
* or some other platform by examing the "os.name" property.
* @return true if this application is running under a Windows OS
public static boolean isWindowsPlatform()
String os = System.getProperty("os.name");
if ( os != null && os.startsWith(WIN_ID))
return true;
else
return false;
* Simple example.
public static void main(String[] args)
displayURL("http://www.javaworld.com");
// Used to identify the windows platform.
private static final String WIN_ID = "Windows";
// The default system browser under windows.
private static final String WIN_PATH = "rundll32";
// The flag to display a url.
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
// The default browser under unix.
private static final String UNIX_PATH = "netscape";
// The flag to display a url.
private static final String UNIX_FLAG = "-remote openURL";

Similar Messages

  • Why can't I open html documents in Pages 3.0 but could in v2.0.2?

    We used Pages v2.0.2 to open html exam documents to reformat the exams before sending to the printer. We recently upgraded to Pages 3.0 via iWorks '08, and we can no longer open html documents. Does anyone know if this is just an oversight in Pages 3.0 and will be fixed in future updates or has Apple intentionally abandoned html support in Pages?
    We need to find a workable solution. We prepare exams for 1000s of students each semester.
    Thanks in advance.
    Best Regards,
    Rick

    Pages 3.0 (that is iWork '08) doesn't have an HTML entry in the CFBundleDocumentTypes of it's Info.plist file. Pages 1.x and 2.x both DO have an HTML entry in their Info.plist files. Thus Pages 3 won't open HTML while Pages 1 and 2 both will.
    So the questions are:
    Why did Apple remove HTML as a file type for Pages v3.0? Was it a mistake? Was it intentional? Will it come back in a quick update to Pages?
    And then again for you Allan Eckert:
    How are you able to open HTML documents in Pages v3.0? By rights, any ".html" file shouldn't be openable in Pages v3.

  • Opening html document.

    Hi all,
    I am trying to use java code to open a html document called "about.htm". At the moment I have the following code:
    public AboutDialog(Frame parent)throws IOException
         Runtime rt = Runtime.getRuntime();
         Process p = rt.exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe  D:\\Work\\about.htm");
         }Although this code works the problem is if I transfer it to another PC which does not use Internet Explorer I want it to open using whatever the default program is (ie.Firefox).
    In other words I want to remove the line C:\\Program Files\\Internet Explorer\\IEXPLORE.exeAny help would be appreciated.

    FebTen wrote:
    Change the statement like this. It works
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("cmd.exe /C start C:\\Progra~1\\DinPro\\about.html");No, absolutely not the right way to do it. That is unreliable as it assumes the short name of "Program Files" is always "Progra~1", which is not necessarily true. If there happened to be a couple of folders named, for example, "Program Files" and "Programmers R Us", both of those would have short names like "Progra~1" and "Progra~2" (or somesuch), and you can't be certain which one will map to "Program Files".
    The true solution is to do as DrClap said.
    Process p = rt.exec("cmd.exe /C start \"C:\\Program Files\\DinPro\\about.htm\"");Alternatively (and a better way) you can use the various flavors of Runtime.exec, passing it an array of strings, and it will insert the correct quotation marks around the ones containing embedded spaces. Something like:
    String[] args = { "cmd.exe", "/C", "start", "C:\\Program Files\\..." };
    Process p = rt.exec(args);Check the API documentation.

  • Unable to open HTML documents saved with Firefox 3.0.6

    After downloading complete web pages using Firefox, I am unable to open the html document using Firefox in Linux (it is no problem with Opera). I consistently receive this Firefox error message:
    File Not Found
    The file /home/richard/Documents/ . . . cannot be found. Please check the location and try again.
    * Could the item have been renamed, removed, or relocated?
    * Is there a spelling, capitalisation, or other typographical error in the address?
    * Do you have sufficient access permissions to the requested item?

    Next you give Steve Jobs more money as he intended.

  • How to open HTML documents in Apple Mail?

    I received an e-mail with two attachments.  It says "HTML" and tries to open in Safari.  All the content is disorted, how do I open these attachments on my mac without it being distorted?  I have also tried TextEditor, same issue.
    Please help!

    In the mailbox list, below the word "MAILBOXES" and the standard mailboxes (Inbox, Drafts, Sent, Trash, & Junk), you should have some lines like "SMART MAILBOXES", "REMINDERS", "RSS", "ON MY MAC", and a line with the name of each of your mail accounts. Each of those lines may have subordinate lines indented below it, or they may be hidden. Before Lion, the top-level lines would have standard disclosure triangles to their left like folders, but Lion Mail removed that visual clue in favor of a word "Show" or "Hide" to the right that appears only when you mouse over it.
    The Gmail Spam folder you seek is two folders deep inside your Gmail account.
    Here's my Gmail account listing:
    It has 41 unread messages. If I hover my cursor over the oval with "41" in it, the oval shifts left and "Show" appears. If I click on "Show", I get this:
    If I click on the disclosure triangle left of the "[Gmail]" folder, voila!
    By the way, this intermediate "[Gmail]" folder is specific to Gmail, Google Apps mail sites, and other mail sites using Google's Gmail code, as is the All Mail folder. Other servers will have their own folder structure.

  • Hotkey for switching between open html pages similar to Apple+Tab for apps

    Is there a hotkey combination which can switch between open html documents in the same way Apple+Tab switches between open applications?
    In Windows it is possible to switch use ALT+TAB to switch between various open Firefox windows which are displayed as options along with other open applications -- but OSX seems to limit choices only to applications, and not their various windows. ?
    Thanks

    Hmm...sorry...just switched yesterday afternoon...this combo though doesn't seem to be working for me in either Firefox or Safari...tried Command+< also with the SHIFT key for '<' but to no avail.
    Mind if I ask a two more simple questions though? How can the touchpad be setup to automatically register a click by tapping on the touchpad rather than the button beneath it...and...is there a hotkey combo which would take a person back to the beginning of a text field, similar to 'Home'? Haven't yet figured out how to make the arrow with "home" on it actually send the cursor back to "home"...
    many thanks

  • Html documents & safari

    When opening html documents in safari it just displays all the html code on the screen instead of loading the webpage. I tried opening several different documents thinking one contained an error but they all do the same thing just display the html code instead of loading a webpage. Any ideas?

    i found convert to plain text and used that still does the same thing
    If you are composing html in textedit, you must first go to the preferences and set "new document" to plain text. Also check the box for "ignore rich text commands in html" under When Opening a File. Then when you Save, add the .html extension manually.

  • Safari won't open webarchives or html documents stored on computer

    I occasionally save a webpage to my computer as a .webarchive for later usage, but anytime I try to open them safari takes me to a completely different page. It brings me to my Top Sites page that shows all of my most frequently visited pages. I don't understand why safari would do this since the way the document is created is by saving the page directly in safari (command + S). I noticed the problem initially when Safari wouldn't open an html document that I had created and stored on my computer. I used the page as my homepage because it had links to all of my most frequent websites and because I liked having my own creation as my home page (that doesn’t really matter, though) and then out of nowhere when I opened safari my homepage had been changed to Yahoo (my default engine) and the html document wouldn’t open at all. I thought that maybe the problem was due to a recent update because I noticed that two new tabs were added to the toolbar (ebay and amazon), but I don’t understand why an update would make it so that .webarchive files, created by safari, wont open. I checked my safari version, it is 7.0.3, and if it helps, the html documents that won't open were made with Adobe Dreamweaver. I would really appreciate if someone could tell me what is happening because I do need to be able to open the .webarchive files I have saved in the past. Thank you.

    Carolyn, I've told you repeatedly, that site's instructions are crap. They absolutely do not fully remove the Genieo adware. In fact, the uninstaller that site refers you to will actually install components of the adware that were not already present! For the same reason, it makes no sense to rely on Genieo's instructions. I am completely mystified as to why you continue to post these suggestions.
    To properly remove Genieo, see:
    http://www.thesafemac.com/arg-genieo/
    (Fair disclosure: The Safe Mac is my site, and contains a Donate button, so I may receive compensation for providing links to The Safe Mac. Donations are not required.)

  • Unable to open html file in document library without saving first

    I've uploaded a bunch of HTML files from a DVD to a document library on our Sharepoint 2013 Enterprise server. When I try to open one of the html files it wants to save the file instead of opening it. If I choose to open the document library in Explorer
    I'm able to open the html files w/o issue.
    What's causing this? I know there is an option to set the file handing to permissive, but I'd rather not do that.

    Carl,
    See this link - http://sharepoint.stackexchange.com/questions/39020/how-do-i-prevent-sharepoint-from-asking-to-download-html-files-to-my-local-machi
    The allowed mime types are defined in theSPWebApplication.AllowedInlineDownloadedMimeTypes
    Property
    Here is small PowerShell utility function I use:
    function Add-SPAllowedInlineDownloadedMimeType{
    [CmdLetBinding()]
    param(
    [Parameter(Mandatory=$true, Position=0, ValueFromPipeLine=$true)]
    [Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]$WebApplication,
    [Parameter(Mandatory=$true, Position=1)]
    [string]$MimeType
    process{
    $actualWebApp = $WebApplication.Read()
    if ($actualWebApp.AllowedInlineDownloadedMimeTypes -notcontains $mimetype)
    Write-Host "Adding MIME Type..."
    $actualWebApp.AllowedInlineDownloadedMimeTypes.Add($mimetype)
    $actualWebApp.Update()
    Write-Host "Done."
    } Else {
    Write-Host -ForegroundColor Green "MIME type is already added."
    And it can be used like this:
    Add-SPAllowedInlineDownloadedMimeType -WebApplication http://mywebapp -MimeType "text/html"
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • Opening a html document in order to load a certain website (and login), results in opening the startpage(s) from FireFrox.

    we use a html document to automatically login out application. but when this document opens FireFox always opens the startpage. When FireFox is already running the html document works as intended.
    no problems with IE.

    Unfortunately, Java standard API can't handle PDF file as a distinct document.
    However, you could use a physical URLConnection to get any file content as
    a simple byte mass.

  • How to get Safari to open an HTML document created in AIR on iOS

    We have an iOS app that creates a 3-page HTML document on the user's device and then prints it. We were using Darkredz ANE to do this, but the ANE is broken in iOS 8 and the Darkredz website is abandoned.
    As a workaround, we want to use Safari to launch the HTML document, then print from Safari. But Safari won't open a local document that belongs to another app, probably because of the security sandbox. We don't have a network connection, so we can't save the file remotely. Is there a way to get Safari to open a local document?
    If not, does anyone know of a FileManager app that can open files that are located in the "documents" folder of other apps on the device? I've tried several of them, but so far, they only load files from iCloud, Box, etc.
    Thanks for any tips.

    Sorry I didnt think about it needing to print as 3 separate pages at specific points. If you can't get the HTML printing to work then you could keep could this thought in mind. If the height of the, I presume, HTMLLoader object is the right value, you can draw the white-space of the page into the BitmapData and then it might still print at the right location. If it doesn't work immediately and you felt like putting in a little more effort, you might be able to tweak the height of the HTMLLoader objects so that each one represents a single page. Granted this approach would likely only work for one paper size format, such as 8.5x11. Sorry I don't have any easier ideas that work with what you already have done so far

  • Html documents in webServer/documents folder I can't open...

    Hi all,
    For a while now I've been researching on how to use a mac as a webserver to host my sites.
    I know that to get users to access sites fromt the server without having to use user folders I'll have to store my sites in the HDD's library/WebServer/Documents folder.
    Well, having a look at this folder it is filled with some form of HTML documents, such as Index.html.en, Index.html.cn etc etc. I gather that these are different language variations of an index html document. However because of the html.en extension etc I can't seem to open the document in a web browser, I can open it in textedit and it confirms it is a html doc.
    Why can this not be opened? do they need to be deleted and replaced with my own sites if I use my mac as a webserver?
    Thanks

    Hi--
    Well, having a look at this folder it is filled with
    some form of HTML documents, such as Index.html.en,
    Index.html.cn etc etc. I gather that these are
    different language variations of an index html
    document. However because of the html.en extension
    etc I can't seem to open the document in a web
    browser, I can open it in textedit and it confirms it
    is a html doc.
    You're right, these are localized language variations of the default Apache welcome page. You should be able to open them by dragging them to a web browser window. Apache doesn't server those pages out as a result of a direct request, but as the result of a content negotiation. In other words, if someone requests French pages, they'll get index.html.fr as a result. There's more information about it in the Apache docs on the subject.
    do they need to be
    deleted and replaced with my own sites if I use my
    mac as a webserver?
    You can delete them if you want. The one relating to the Apache manual is the symbolic link called "manual". If you want to be able to type http://localhost/manual/ into your browser to get the manual, I'd leave it.
    One warning, though: sometimes, as a result of a software update from Apple, those files will all get placed there again (I don't think they'll overwrite existing files, however). I don't know how often that's happened recently, though, as I've done as Tim suggested in his post and moved all my web sites to their own folders and pretty much ignore the default one.
    charlie

  • HTML Document: How to open in IE window without frame?

    Dear SDN members,
    We have created some HTML help documents for our ESS users. We added an icon to the different ESS WD iViews and when clicked, these icons link to the HTML file with the help text in it.
    Please see what I mean in the next screenshot:
    http://tweakers.net/ext/f/pq1y8uVy7mICDwDLU0LS4Foz/full.jpg
    My question is: How can I make sure that when the icon is clicked, the HTML document is opened in a new IE window, but without frame? So no toolbars, address, etc.
    Does anyone have an idea? Any help will be highly appraciated an points will be awarded.
    Thanks in advance and best regards,
    Jan Laros

    BUMP. Any suggestions?
    Ihave managed to fix this using JavaScript in a KM text document. This Script links to an HTML document with the correct texts. In the script I can give the properties of the popup, but this is not working on our QAS systems with Reverse Proxy and SSL configured. Any help is highly appreciated.
    Best regards,
    Jan
    Edited by: Jan Laros on Mar 4, 2008 2:24 PM

  • Wanting to open a HTML document in users default browser using Menu Items

    I have a couple of Menu items that I want to open up various HTML documents.
    menuHelpItem.addActionListener(new ActionListener()
         public void actionPerformed(ActionEvent evt)
    });I've seen a couple of 'solutions' to people asking about opening files, but none even compiled never mind ran. It's in my parent program, and any solution needing to throw IOException (lots of things annoyingly seem to) that'll mean the listeners need to which never seems to work. Even if it did though, the class would have to and so would all the others. Messy.
    Best I've done is open up a new JEditorPane based on the url of the HTML files, but this is definately not good enough as the font, layout, links are all screwed and if I could fix it, it would no doubt take longer than I have.
    So basically, say you have a button, how do you make it open "resources/SearchHelp.html"?

    "http://www.google.com"; //
    Interesting. I changed my code to this:
    private void showHelp(String url)
         try
              String[] cmd = new String[5];
              cmd[0] = "cmd.exe";
              cmd[1] = "/C";
              cmd[2] = "rundll32";
              cmd[3] = "url.dll,FileProtocolHandler";
              cmd[4] = PronunciationDictionary.class.getResource(url).toString();
              Process process = Runtime.getRuntime().exec( cmd );
         catch (IOException e)
              JOptionPane.showMessageDialog(this, "Unable to load help file. Please try again.", "Help - Dictionary A'la Lewis", JOptionPane.INFORMATION_MESSAGE);
    }and I printed out PronunciationDictionary.class.getResource(url).toString(); before trying it and that worked fine. I click on the buttons but nothing happens, no error which is good, but nothing else either, which is bad. I thought maybe I was just doing it wrong, so I tried replacing it with just http://www.google.com but same thing, nothing happened at all.

  • How to open word document form html container url iam getting internal_error while opening file

    Hi all,
    By using below code i am able to download word document file from html container. But before downloading i need edit these document to add Macro.
    I am unable to open word document.
    CREATE OBJECT G_HTML_CONTAINER
          EXPORTING
            CONTAINER_NAME = 'PDF'.
       CREATE OBJECT G_HTML_CONTROL
          EXPORTING
            PARENT = G_HTML_CONTAINER.
    * Convert xstring to binary table to pass to the LOAD_DATA method
        CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            BUFFER     = LV_CONTENT
          TABLES
            BINARY_TAB = LT_DATA.
    data_tab = LT_DATA ).
    * Load the HTML
        CALL METHOD G_HTML_CONTROL->LOAD_DATA(
           EXPORTING
             TYPE         = 'application'
             SUBTYPE      = 'DOC'
           IMPORTING
             ASSIGNED_URL         = LV_URL
           CHANGING
             DATA_TABLE           = LT_DATA
           EXCEPTIONS
             DP_INVALID_PARAMETER = 1
             DP_ERROR_GENERAL     = 2
             CNTL_ERROR           = 3
             OTHERS               = 4 ).
    * Show it
        CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL
          IN_PLACE = 'X' ).
    Before file download i want edit the file for that i am using below class.
    PROXY TYPE REF TO I_OI_DOCUMENT_PROXY.
    by using (get_document_proxy) method  getting proxy .
    call method control->get_document_proxy
    exporting
    document_format   = 'x'
    document_type      = 'Word.Document'
    register_container  = 'x'
    importing
    document_proxy     = proxy
    after these.
    call method proxy->open_document
    exporting
    document_url    = lv_url
    open_inplace    = 'x'
    hear i m getting retcode as INTERNAL ERROR
    can any one suggest me how to open document from html container.
    Thanks and reagards
    jogu yadav

    I got resolution
    Thanks and regards,
    Jogu yadav

Maybe you are looking for