How to open a web browser from java

Hi
Would anybody please help me with this. I need to open a web browser from my java app but I don't know. What method I can use?
Thanks.
Hung.

You can use the Runtime class for this. It can run any command. So, you can run the .exe file of your Web browser.
The following code will run Internet Explorer (assuming iexplorer.exe is in C:\Program Files\Internet Explorer):
import java.lang.Runtime;
public class Explore{
public static void main(String[] args) {
try{
Process p = Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore");
}catch (Exception e) {
System.out.println("Exception: " + e);

Similar Messages

  • How to open a web browser from an windows phone app

    Hi everyone,
    I am pretty new to Windows Phone 7, and now what I am trying to do is to create a simple app. When a user click to start this app, a browser will open and show the content of a webpage from a specific address.
    I tried to use a webbrowser object, but it seems like that doesn't sport cookies. So I need my app to open a real web browser (maybe IE mobile) to do the job.
    Thank you.

    copying from stackoverflow: "If you want to embed a browser window inside your application then use  the WebBrowser control.  Add an instance of the WebBrowser control to  your form then you can reference it in code using the name you
    give  it.  (Default name is "webBrowser1")"
    Microsoft MVP J# 2004-2010, Borland Spirit of Delphi 2001

  • Open web browser from java application to specific page

    Hi,
    I used the code from http://www.javaworld.com/javaworld/javatips/jw-javatip66.html to open a web browser to a specific URL. That worked great! However, I run into a problem if the URL targets a specific page, for example, "http://www.yahoo.com/news.html" would give me an problem with the shortcut problem. Any ideas how to get around that?
    The command rundll32 url.dll,FileProtocolHandler http://www.yahoo.com/news/ would work fine, except anything ends with .htm or .html.
    Thanks,
    David

    It looks like url.dll doesnt like .htm or .html files. For more info look here: http://www.jsiinc.com/SUBI/tip4100/rh4162.htm
    For some reason it is confused by the 'm' character in .html which is odd considering it has no problems with .com
    So if you want to keep using url.dll, do something like this:
    replace ".htm" with ".ht%6D"

  • Opening a web browser from an After Effects script

    Hi,
    This may be a stupid question, but is there any way to open a web browser with a URL from an AE script, other than explicity lanuching the browser app via a sys.callSystem() command?
    I'm asking because obviously scripts need to run on both Windows and MacOS, and the user's default/preferred browser isn't necessarily going to be IE or Safari. That and I'd need to find the file path of the browser anyway somehow.
    It's to display external help.
    Thanks,
    Christian

    system.callSystem() can launch a URL without specifying the specific app. This code user's default browser. The last line is the main deal, the other stuff keeps it universal for PC and MAC.
    //CHECKS FOR USER OS
    function osCheck(){
              var op = $.os;
              var match = op.indexOf("Windows");
              if(match != (-1)){
                        var userOS = "PC";// User is on PC
              }else{
                        var userOS = "MAC";// User is on MAC
              return userOS;
    // RUNS OS CHECK FUNCTION
    var userOSVer = osCheck();
    //DEFINES PC OR MAC TERMINAL SYNTAX
    if(userOSVer == "MAC"){
              var urlLaunchCode = "Open";//Mac based
    }else{
              var urlLaunchCode = "Start";//PC based
    //ONCLICK FUNCTION FOR YOUR URL BUTTON CONTROL
    //urlLaunchCode = Open or Start / " " = keeps a space character separator / "http://myurl.com" = Defines the actual URL path
    myURLButton.onClick = function(){system.callSystem(urlLaunchCode + " " + "http://forums.adobe.com/thread/993523?tstart=0")};

  • Can open a Web browser from the worksapce?

    Hi,
    we are using Adobe livecycle ES2.5, We are trying to add an action to our users to open a specific URL in a Web browser, is it doable?
    Thanks
    Hussam

    Thanks Nith,
    we did this before when using pdfs but in our case we are using Flex and we do not want to call the web browser from the flex we need it from the workspace directly,
    please see the attachment, when the user clicks complete we want to open the browser instead of submitting the form to the next step.
    any idea?
    Regards

  • How to open a brio Query from Java

    Hi,
    I am working with Hyperion Intellegence Explorer to take care of the MIS related activities, to pull out the Data from the Data Base and Export it to the Excel
    Actually this is a BAU.
    So i want to reduce my work burdon. I am a Java Progrrammer too. So i want to automate all the thing from Java.
    Pls help me below to open a Brio files from Java,so that i can proceed to process the Query and export it on to the Excel.,

    Don't double post the same question. You can continue in your previous thread
    [http://forums.sun.com/thread.jspa?threadID=5367120]
    I'm locking this one and it will be removed it later.
    db

  • Opening a web browser from a Java prog

    I am writing a pseudo-wordprocessor, and would like to be able to set a JMenuItem's action so that when a user clicks it, the system default web browser opens with the web page that I have selected. (e.g. open up a "Help" web page).
    The JavaDoc/tutorial doesn't seem to have anything on running external programs from within a Java program, so does nayone know how this is done?

    If you don't want to go the Java Runtime route and make your program a bit more cross-platform friendly, you could use the JEditorPane to render an html page directly in your application (assuming of course that you're using Swing).

  • How to open a new browser from applet

    I have a Applet that run in a browser. How I can open the second broswer from the Applet. Make sure the first browser for Applet is still existing. Thanks anybody help!!

    I think you might do something like this:
    try {
    getAppletContext().showDocument(new URL("http://web.com", "_blank");
    } catch (MalformedURLException me) {
    System.out.println(me.getMessage());
    Hope this work out for you...
    /Tomas

  • How to Trigger CAF web services from java Job schedulers?

    Hi Experts,
    I am in need of calling CAF based web services from custom Job scheduler.
    Could you please provide your idea and input if anyway we can call such web service by java api in custom jobs development?
    Thing is that we have CAF BO which hold around 1 million record (master data) and based on approval scenario (developed in WDJ apps) we will have to move this record to another business object for further manipulation?
    Hence due to huge number of record in BO, I would like to automate this activity by calling Jobs from WDJ apps and then Job will trigger the CAF web service which would create record into the BO object.
    Please share your idea and let me if it can be achievable by java apis to trigger Jobs by WDJ apps & webservice by jobs?
    Thanks & Regards,
    Pankaj

    Hi Experts,
    I am in need of calling CAF based web services from custom Job scheduler.
    Could you please provide your idea and input if anyway we can call such web service by java api in custom jobs development?
    Thing is that we have CAF BO which hold around 1 million record (master data) and based on approval scenario (developed in WDJ apps) we will have to move this record to another business object for further manipulation?
    Hence due to huge number of record in BO, I would like to automate this activity by calling Jobs from WDJ apps and then Job will trigger the CAF web service which would create record into the BO object.
    Please share your idea and let me if it can be achievable by java apis to trigger Jobs by WDJ apps & webservice by jobs?
    Thanks & Regards,
    Pankaj

  • Opening new default browser from java app

    Hi There,
    I would like to know if there is away to execute the following in a Java app that will open a new browser window.......in other words, I don't want it to take over the already opened window - just open a new window every time.
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
    www.google.co.nz");Any help with this would be greatly receievd.

    There might be. However it would be done by modifying that Windows-specific command that you have in red there. As such it's nothing to do with Java. Searching in Windows-specific websites might get you somewhere.
    However Firefox gives the choice (new window, new tab, or same tab in same window) to the user as a configuration option, so I wouldn't bet on getting somewhere. I don't know if IE has a similar configuration option.

  • How to open an existing file from java

    Hi Guys,
    I have one problem Please help me in this.
    How to open file(i.e. file can be any type, it is may be image file, doc file or pdf file) using java.
    Even i tryed in one way but it is static way that is working in windows not for other OS.
    Code :
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
         DataInputStream din=new DataInputStream(System.in);
         System.out.println("Enter File Path to Open");
         String fName=din.readLine();
         File file=new File(fName);
    Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file.getAbsolutePath());
    catch (Exception err) {
    err.printStackTrace();
    If any other way to do please tell me.
    Regards
    Siva Prasad

    Well, if the OS doesn't provide a mechanism to associate a file name with a certain program, there's nothing you can do.
    I don't know whether something like JDIC can help you - otherwise, you'd have to find the solution for each OS. What's inside the exec()'s parenthesisses is not a Java problem anymore.

  • How to launch a web browser from a MAC java app

    I know, this topic has been brought up over, and over, however I couldn't find info regarding MAC environments. I don't have any former experience with MAC, but now I'm getting desperate for a solution. I need to be able to pop up the default browser showing a certain URL on MAC/OS from a java application. Any clue would be appreciated.
    Thanks a lot,
    michael berdan

    I wrote libraies that will do this:
    http://ostermiller.org/utils/Browser.html
    I also keep a list of other resources to help you out:
    http://dmoz.org/Bookmarks/D/deadsea/Java_Help/Web_Browser/
    Stephen

  • How to open an PDF file from Java Application

    Hi
    I am developing a GUI application in java swing.
    on clicking one button, I want to open PDF file from my swing application.
    Is there any API through which I can achieve this?
    Tapan Maru
    Sun Certified Java Programmer

    Here's a way to do it (if I understand you
    correctly). Just let explorer.exe do it for you.
    import java.awt.*;
    public class openPDF
         Desktop desktop = Desktop.getDesktop();
         public openPDF()
              open("test.pdf");
         public void open(String path)
              try
                   Runtime.getRuntime().exec("explorer.exe "+path);
    } catch(Exception e) { System.out.println("NAI!
    I! ERROR!\n"+e); }
         public static void main(String[] args)
              openPDF myApplication = new openPDF();
    Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)???
    -Puce

  • 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

  • How to open a web page in java in Solaris system

    i can do this in windows:
    String location = "www.sun.com";
    Runtime.getRuntime().exec("explorer " + location);how could i get it in solaris?
    Thanks

    Isn't this question completely outside the scope of this forum ?
    ... this is a forum for Solaris Zones, not Java or software development.
    http://forum.java.sun.com/thread.jspa?threadID=5075398
    Perhaps your query would be more appropriate in one of these other areas of discussion:
    http://forum.java.sun.com/index.jspa?tab=java

Maybe you are looking for

  • Sender Adapter Mail Problem

    Hello All, on PI 7.0, i have a scenario MAIL -> PI -> MAIL. I've configured the sender mail adapter in order to keep attachment and using pop protocol. When i test, the problem is that everything is green in the CC monitoring but it doesn't take any

  • Play .3gp-files with JMF (jffmpeg)

    Hello, for a MMS-Application I'm trying to show 3gp-files with Java. I heard that it should work with jffmpeg but I still couldn't get it to work. I added the Codec: String JFFMPEG_VIDEO = "net.sourceforge.jffmpeg.VideoDecoder"; try {     Codec video

  • Social Sharing preference in sidecar.xml?

    Hi, I saw that <hideFromTOC> has been added to the sidecar.xml informations. Is there also a preference to set the social sharing protection behaviour? Regards, Yves

  • How to remove the ^M character?

    I'm porting applications from Windows to Solaris. My cpp programs failed to compile in some cases because of the ^M characters at the end of each line. Does anyone know how to remove them systematically? The applicaiton has hundreds of files. It's pr

  • Bootcamp selection screen fuzzy

    I've noticed in the last few days when I'm at the Bootcamp drive selection screen the type is very fuzzy. You can barely read the drive names below the icons. Once the computer finishes booting everything seems fine regardless if you choose the Windo