1

I want to open Internet Explorer from Java in Windows server 2008. I searched online before posting but I still cant do it.

This is my code :

    try {

        Process p = Runtime.getRuntime().exec("cmd.exe /c start iexplore www.google.com");

       p.waitFor();

    } catch (IOException e) {
       //log
    } catch (InterruptedException e) {
       //log
    }

This works fine in a simple Java project I created on my laptop, but doesnt work in a java class I have in work on a windows server 2008.

The application is made using a CRM, the CRM offers the possibilty to add a button linked to a java class. once the button clicked, the java class is launched.

I tried making a windows batch file where I launch Internet explorer and then print something in a log file. When I click manually on the batch file, Internet explorer is launched and the log file created. But when I call the batch file from the Java class, the log file is created but internet explorer isnt launched.

The CRM is linked to a windows user member of the group 'administrators'.

Thank you for any help you can provide.

EDIT:

Like I said The CRM is linked to a windows user. I noticed in the windows task manager that after I click the button the process iexplore.exe is created, so the code works fine, but the process owner is the user linked to the CRM, and the not the one I use to log in, so I guess thats why it seems that the browser isnt launched.

Any clue to get around this ?

Thank you again.

NaoufalB
  • 11
  • 2
  • Have a look here http://stackoverflow.com/questions/5226212/how-to-open-the-default-webbrowser-using-java – SubOptimal Apr 09 '15 at 14:37
  • Thank you, Like I said, the java code doesnt work. – NaoufalB Apr 09 '15 at 14:51
  • Are you able to start a CMD session that way you have started the batch file? Are you able to start the browser from within this CMD session? Do you get error messages? – SubOptimal Apr 10 '15 at 05:38
  • I dont get any error, it seems that the code works just fine but I still cant see the browser, I edited my question to add more informations. – NaoufalB Apr 10 '15 at 12:15
  • You mean if you start from this CMD session any GUI program you can only see it running in the taskmanager but not visible GUI? What is the output of `whoami` in this CMD session? I would expect it's not your user. On a Linux machine I would say the user has no access to the X Server. But I don't know if this is possible on a Windows box. – SubOptimal Apr 10 '15 at 12:48
  • Yes, the output of whoami in the java class is "Domaine name\The user linked to the CRM", as expected, it's not my user. Do you think there is a way to get around this ? – NaoufalB Apr 10 '15 at 13:52
  • Maybe it's linked to this post [why-cant-windows-services-have-a-gui](http://programmers.stackexchange.com/questions/180833/why-cant-windows-services-have-a-gui) – SubOptimal Apr 10 '15 at 14:29

0 Answers0