Opening a web page from a JButton

Dear all,
I'm trying to program a JButton from my GUI program that will open up a web page on Microsoft Internet Explorer window.
Can anyone tell me how to do this?
Regards,
Raheal

Try the DOS "start" command:If all else fails,
import java.lang.reflect.Method;
import javax.swing.JOptionPane;
public class test {
    public test() {
     public static void main(String[] args) {
      String osName = System.getProperty("os.name");
      String url = "http://www.slashdot.org";
      try {
         if (osName.startsWith("Mac OS")) {
            Class fileMgr = Class.forName("com.apple.eio.FileManager");
            Method openURL = fileMgr.getDeclaredMethod("openURL",
               new Class[] {String.class});
            openURL.invoke(null, new Object[] {url});
         else if (osName.startsWith("Windows"))
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
         else { //assume Unix or Linux
            String[] browsers = {
               "gnome-open", "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
            String browser = null;
            for (int count = 0; count < browsers.length && browser == null; count++)
               if (Runtime.getRuntime().exec(
                     new String[] {"which", browsers[count]}).waitFor() == 0)
                  browser = browsers[count];
            if (browser == null)
               throw new Exception("Could not find web browser");
            else
               Runtime.getRuntime().exec(new String[] {browser, url});
      catch (Exception e) {
         JOptionPane.showMessageDialog(null, e.getLocalizedMessage());
}

Similar Messages

  • Opening a WEB page from FORMS CS & WebForms

    Hi,
    We would like to open a Web Page from a forms running in
    client/server as well as from a form runningover the web.
    Over the web, we plan to use SHOW_DOWUMENT (Even tough it seems
    broken, on forms 6.0, the only way we have got it working was by
    using the parameter that overwrites the current page (the form),
    we cannot have it open an URL in another window)
    In C/S mode, the SHOW DOCUMENT does not work. What is the proper
    way to lauch an URL in a browser in C/S mode ?
    Is there a way to determine if we're running in CS mode or Web
    Mode ? We would like to use the same code both on the web and in
    C/S
    Example pseudo code:
    if (Running in CS Mode) then
    open the URL using C/S method
    else
    open the URL with show dowument
    fi
    Thanks
    null

    use '_blank' as parameter, not '_self'.
    Guy Dallaire (guest) wrote:
    : Hi,
    : We would like to open a Web Page from a forms running in
    : client/server as well as from a form runningover the web.
    : Over the web, we plan to use SHOW_DOWUMENT (Even tough it
    seems
    : broken, on forms 6.0, the only way we have got it working was
    by
    : using the parameter that overwrites the current page (the
    form),
    : we cannot have it open an URL in another window)
    : In C/S mode, the SHOW DOCUMENT does not work. What is the
    proper
    : way to lauch an URL in a browser in C/S mode ?
    : Is there a way to determine if we're running in CS mode or Web
    : Mode ? We would like to use the same code both on the web and
    in
    : C/S
    : Example pseudo code:
    : if (Running in CS Mode) then
    : open the URL using C/S method
    : else
    : open the URL with show dowument
    : fi
    : Thanks
    null

  • Open a web page from Oracle

    plz, i use oracle 10g but how can i open/ping a web URL from pl/sql code?

    Thank you venky but you should post the link as link and not between tags !
    [Re: Opening a web page from oracle
    SS                                                                                                                                                                                                                                                                                                                                               

  • Opening a web page from oracle

    Hi ,
    How can i open a web page example : "www.yahoo.com" from pl/sql ?
    One more thing , if this was possible is there a way to provide the username/password to the website to be logged on right when the page is browsed ?
    also how does Oracle know of the browser that is going to be used ?
    Thanks...

    CREATE OR REPLACE PROCEDURE show_url
        url      IN VARCHAR2,
        username IN VARCHAR2 DEFAULT NULL,
        password IN VARCHAR2 DEFAULT NULL
    ) AS
        req       utl_http.req;
        resp      utl_http.resp;
        name      VARCHAR2(256);
        value     VARCHAR2(1024);
        data      VARCHAR2(255);
        my_scheme VARCHAR2(256);
        my_realm  VARCHAR2(256);
        my_proxy  BOOLEAN;
    BEGIN
    -- When going through a firewall, pass requests through this host.
    -- Specify sites inside the firewall that don't need the proxy host.
      utl_http.set_proxy('proxy.my-company.com', 'corp.my-company.com');
    -- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
    -- rather than just returning the text of the error page.
      utl_http.set_response_error_check(FALSE);
    -- Begin retrieving this Web page.
      req := utl_http.begin_request(url);
    -- Identify ourselves. Some sites serve special pages for particular browsers.
      utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
    -- Specify a user ID and password for pages that require them.
      IF (username IS NOT NULL) THEN
        utl_http.set_authentication(req, username, password);
      END IF;
      BEGIN
    -- Start receiving the HTML text.
        resp := utl_http.get_response(req);
    -- Show the status codes and reason phrase of the response.
        dbms_output.put_line('HTTP response status code: ' || resp.status_code);
        dbms_output.put_line('HTTP response reason phrase: ' || resp.reason_phrase);
    -- Look for client-side error and report it.
        IF (resp.status_code >= 400) AND (resp.status_code <= 499) THEN
    -- Detect whether the page is password protected, and we didn't supply
    -- the right authorization.
          IF (resp.status_code = utl_http.HTTP_UNAUTHORIZED) THEN
            utl_http.get_authentication(resp, my_scheme, my_realm, my_proxy);
            IF (my_proxy) THEN
              dbms_output.put_line('Web proxy server is protected.');
              dbms_output.put('Please supply the required ' || my_scheme ||
                ' authentication username/password for realm ' || my_realm ||
                ' for the proxy server.');
            ELSE
              dbms_output.put_line('Web page ' || url || ' is protected.');
              dbms_output.put('Please supplied the required ' || my_scheme ||
                ' authentication username/password for realm ' || my_realm ||
                ' for the Web page.');
            END IF;
          ELSE
            dbms_output.put_line('Check the URL.');
          END IF;
          utl_http.end_response(resp);
          RETURN;
    -- Look for server-side error and report it.
        ELSIF (resp.status_code >= 500) AND (resp.status_code <= 599) THEN
          dbms_output.put_line('Check if the Web site is up.');
          utl_http.end_response(resp);
          RETURN;
        END IF;
    -- The HTTP header lines contain information about cookies, character sets,
    -- and other data that client and server can use to customize each session.
        FOR i IN 1..utl_http.get_header_count(resp) LOOP
          utl_http.get_header(resp, i, name, value);
          dbms_output.put_line(name || ': ' || value);
        END LOOP;
    -- Keep reading lines until no more are left and an exception is raised.
        LOOP
          utl_http.read_line(resp, value);
          dbms_output.put_line(value);
        END LOOP;
      EXCEPTION
        WHEN utl_http.end_of_body THEN
        utl_http.end_response(resp);
      END;
    END;
    SET serveroutput ON
    -- The following URLs illustrate the use of this procedure,
    -- but these pages do not actually exist. To test, substitute
    -- URLs from your own Web server.
    exec show_url('http://www.oracle.com/no-such-page.html')
    exec show_url('http://www.oracle.com/protected-page.html')
    exec show_url('http://www.oracle.com/protected-page.html', 'scott', 'tiger')Reference
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_web.htm#BGBGBFJJ
    !http://download.oracle.com/docs/cd/B19306_01/dcommon/gifs/oracle.gif!

  • How to open a web page from a BSP ? Or swap from the actual URL to another?

    Hi,
    I have a BSP, executing some data loading. It works fine.
    I am trying to enhance it by adding a call to another URL, at the end of the program.
    The same code works when I execute it from transaction SE38. However, when this is executed from the BSP itself, the return code of the function CALL_BROWSER is 2.
    I made som debugs, and the CALL_BROWSER function executes another function which is WS_QUERY. And there, SAP seems not being able to find wich system it is running on.
    Has someone done that before?
    Here is the code of my BSP (the same that works in SE38):
    DATA : appname      TYPE string,
           ls_page_name TYPE string,
           cb_true      TYPE boolean,
           cb_false     TYPE boolean,
           url          TYPE string,
           c_url(2054)  TYPE c.
        MOVE : 'ZPC_STKVTES'     TO appname,
               'zpc_stkvtes.htm' TO ls_page_name,
               'X'               TO cb_true,
               '-'               TO cb_false.
        CALL FUNCTION 'UPWB_GET_APPLICATION_URL'
          EXPORTING
            application          = appname
            page                 = ls_page_name
            ib_additional_params = cb_true
            ib_in_subgui         = cb_false
            ic_preview_type      = 'B'
          IMPORTING
            url                  = url.
        CONCATENATE url '&bps-design_messages=X' INTO c_url.
        CALL FUNCTION 'CALL_BROWSER'
          EXPORTING
            url                    = c_url
            window_name            = ' '
            new_window             = 'X'
          EXCEPTIONS
            frontend_not_supported = 1
            frontend_error         = 2
            prog_not_found         = 3
            no_batch               = 4
            unspecified_error      = 5
            OTHERS                 = 6.
    Regards
    Laurent
    Message was edited by: Laurent THIBERT

    > Thanks, but can I use such technology within Abap?
    YES with report programs or dialog programs but not in BSP framework
    > I use the Event OnProcessing of the BSP to execute
    > many tasks, and then only I want to open or swap to
    > antoher URL.
    in that case you can either use
    navigation->goto_page(<url>) .
    or if you want to open the page in a new window.
    inoninputprocessing after all your processing done youc an set a varialbe say opennewwindow = 'YES'
    and in the layout write this code.
    <% if opennewwindow = 'YES' . %>
    <script>
          window.open( '<%= url %>', target='_balnk');
          </script>
    <% endif . %>
    Regards
    Raja

  • Suddenly I am unable to open a web page from a link in an email (eg notification from facebook) - usually have to unistall and then re-install but this is a nu

    without any changes i am aware of, firefox suddenly stops opening from links in emails (thunderbird).
    e.g. notifications from facebook.
    Usually when this occurs I un-install and then re-install firefox and that fixes the problem but of course it interrupts what I'm doing and takes time. Is there a known cause and fix for this failure to open?

    Make sure that Firefox is set as the default browser.
    *http://kb.mozillazine.org/Default_browser
    *https://support.mozilla.org/kb/How+to+make+Firefox+the+default+browser
    *https://support.mozilla.org/kb/Setting+Firefox+as+the+default+browser+does+not+work

  • Problem opening live web page (url) from within keynote

    hi.
    i encountered this problem during a recent presentation. i have a standard two-monitor set-up, on my laptop viewing notes etc and presenting on the attached monitor. the transitions between my slides are all set onClick.
    so, when i encounter a hyperlink in my presentation (of the web page type), when i click on it, i am not taken to the web page, but rather to the next slide.
    how do i avoid this? how do i make keynote follow the hyperlink -- i.e. open the webpage during the presentation?
    many thanks in advance for your tips.

    use '_blank' as parameter, not '_self'.
    Guy Dallaire (guest) wrote:
    : Hi,
    : We would like to open a Web Page from a forms running in
    : client/server as well as from a form runningover the web.
    : Over the web, we plan to use SHOW_DOWUMENT (Even tough it
    seems
    : broken, on forms 6.0, the only way we have got it working was
    by
    : using the parameter that overwrites the current page (the
    form),
    : we cannot have it open an URL in another window)
    : In C/S mode, the SHOW DOCUMENT does not work. What is the
    proper
    : way to lauch an URL in a browser in C/S mode ?
    : Is there a way to determine if we're running in CS mode or Web
    : Mode ? We would like to use the same code both on the web and
    in
    : C/S
    : Example pseudo code:
    : if (Running in CS Mode) then
    : open the URL using C/S method
    : else
    : open the URL with show dowument
    : fi
    : Thanks
    null

  • Open web page from applet

    Hi guys,
    I am new to Java applet and I need your help. I want to open a web page (or a servlet) with known URL from an applet when I press a button. I know how to set up HttpURLConnection for the applet. But I don't how to open this web page. Could you please help me? What method I should use?
    Many thanks in advance.
    jh

    getAppletContext().showDocument(URL url)
    You should search the forum and then post over here. Also go through the api.

  • TS3276 i am unable to open web pages from email links on my ipad

    I am unable to open web pages from email links on my ipad

    A few more details might help, if nobody else recognizes this.   
    What happens when you try to open the links?
    Can you post an example of a link that doesn't work?
    Is there any particular source for the mail with the (bad) links, or is mail from all sources failing?
    If you happen to know it, what's the format of the mail message?  (Maybe the message is an image?)
    Do the embedded links work as expected from an OS X system running Mail.app, or some system and some other other mail client?
    To view the link in iOS: if you press on and hold your finger on an embedded link in most contexts, iOS will show a pop-up with the link contents, and will offer to copy it.  You can use that to acquire and post the link.  If pressing and holding on the link doesn't offer the pop-up, the format of the link itself may not be valid, or it might not really be a link.

  • How to open web pages from japplet??

    Hi
    Does anybody know how to open web pages from java japplet??
    Any help is apreciated!
    zick

    the getAppletContext() method of the Applet class will get you an AppletContext, with which you can call the ShowDocument(URL url) or ShowDocument(URL url, String target) method...
    check it out at http://java.sun.com/j2se/1.4/docs/api/java/applet/AppletContext.html
    have a good one :)
    Jay

  • Opening a web page in a new tab appear web page from the history

    When I like to open a web page in a new tab, is opening a BLANK page and in the new tab's address bar appear a random web page address from history .

    Try performing a clean reinstall.
    Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thanks,
    cyborg4

  • Open a web page and pass values from a java file

    Hi,
    I need to open a web page and pass values in the text boxes.
    Finally submit needs to be triggered. All this needs to be done from a java file. i.e instead of entering my values in a web page and submit, i need to do it from my java file..
    Any inputs so that I proceed in the right direction..or is there any alternate way to achive this ??
    Thanks in advance..
    Sid

    I hava found a lines of jaa that can open a URL , lets say www.net.java
    You can open it writable or not.
    It is half of the job you need.
    If you are interested.
    I am wrinting a program to print a URL , and have developed this small
    code.
    Angel Portal

  • When I select print from any website article while in Firefox it only prints a blank page. When I open same web pages using Safari, they print fine. Documents in other appliations print fine. Only Firefox documents print blank page.

    When I select print from any website article while in Firefox it only prints a blank page. When I open same web pages using Safari, they print fine. Documents in other appliations print fine. Only Firefox documents print blank page.

    Quit Safari.
    Open the Library folder in your home folder as follows:
    ☞ If running Mac OS X 10.7 or later, hold down the option key and select Go ▹ Library from the Finder menu bar.
    ☞ If running an older version of Mac OS X, select Go ▹ Go to Folder… from the Finder menu bar and enter “~/Library” (without the quotes) in the text box that opens.
    Delete the following items from the Library folder:
    Caches/com.apple.Safari/Cache.db
    Preferences/com.apple.quicktime.plugin.preferences.plist
    Preferences/QuickTime Preferences
    Relaunch Safari and test.

  • Open web pages from an applet

    I'm developing an applet that has to open some web pages.
    The only way I know is to use the method showDocument that
    needs and URL. So, how to pass parameters to the web page?
    I don't want to put them in the URL: everyone can see
    "secret data"!
    Help me, please.

    Take a look at this example that uses a JEditor pane to hold the HTML page.
    //Create a new JEditor Pane
    jep = new JEditorPane( );
    //Ensure the pane is not editable
    jep.setEditable(false);  
    //Use this to get local HTML file
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");
    //add the html page to the JEditorPane
    jep.setPage(fileURL);Ok the core line of code here is this.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");The standard method for accessing a html file via a URL is thus. As you can see its very similar.
    URL fileURL = new URL("http://www.comp.glam.ac.uk/pages/staff/asscott/progranimate/docs/Manual/Manual.htm");this.getClass().getResourse() will return the file location of the class you are working with.
    By doing the following you can access manual.html in a folder called Manual that sits in the same file location as the class file you are using.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");I hope this helps.
    Andrew.

  • Setting of "opening web pages from last session"not works when open next time

    In Options, setting to "open windows & tab pages from last time" does not work. I have tries several time but nothing happens. have written to you earlier also , please help

    ''setting to "open windows & tab pages from last time" does not work.''
    That would be very surprising but a change was made to Firefox 4 to always have the choice of going to History ("Alt+S") and choose "Restore previous session".
    With Firefox 5 coming out in a few days (June 21-22) you might try again then, if the solution the developers built in does not work for you. Do you know about pinning tabs ('''app-tabs''') they persist across sessions as a convenience -- if I really want to keep something permanently then I would bookmark such things as a group. Because they can be closed easily.

Maybe you are looking for