Java method Runtime.getRuntime().exec fails on HP-UNIX to start netscape.

Discussion in 'Java' started by Jakir, Aug 12, 2004.

  1. Jakir

    Jakir Guest

    Hi

    Can any one help me in finding what could be wrong in the following
    sample. Its not able to open Netscape on HP-UNIX.

    I am new to java programming.

    class javaHello {
    public static void main(String[] args) {
    System.out.println("Hello World.\n");
    try
    {
    Runtime.getRuntime().exec("netscape");
    }
    catch(Exception e)
    {
    System.out.println("Failed to execute.\n");
    }
    }
    }


    Thanks & Regards
    Jakir
     
    Jakir, Aug 12, 2004
    #1
    1. Advertising

  2. Jakir

    Liz Guest

    "Jakir" <> wrote in message
    news:...
    > Hi
    >
    > Can any one help me in finding what could be wrong in the following
    > sample. Its not able to open Netscape on HP-UNIX.
    >
    > I am new to java programming.
    >
    > class javaHello {
    > public static void main(String[] args) {
    > System.out.println("Hello World.\n");
    > try
    > {
    > Runtime.getRuntime().exec("netscape");
    > }
    > catch(Exception e)
    > {
    > System.out.println("Failed to execute.\n");
    > }
    > }
    > }
    >
    >
    > Thanks & Regards
    > Jakir


    I cut and pasted your program, compiled it, and ran it.
    I don't have netscape so I changed "netscape" to "notepad.exe"
    and it worked fine. Perhaps you need "netscape.exe" or maybe
    netscape.exe is not in your path.
     
    Liz, Aug 13, 2004
    #2
    1. Advertising

  3. Jakir

    Jakir Guest

    Thanks for the responses.

    The command "which netscape" returns "/usr/local/bin" and I had given
    that path
    but still it dosen't work. Also I don't get any error message. The
    output hello is seen and then nothing happens.

    Regards
    Jakir

    Gordon Beaton <> wrote in message news:<411c6181$>...
    > On 13 Aug 2004 08:10:07 +0200, Tor Iver Wilhelmsen wrote:
    > > (Jakir) writes:
    > >> Runtime.getRuntime().exec("netscape");

    > >
    > > You need the explicit path to the executable. Runtime.exec() does
    > > not see the path.

    >
    > Looks to me like the PATH _is_ searched:
    >
    > [foo]$ strace -f java Exec mozilla 2>&1 | grep mozilla
    >
    > stat64("/home/gordon/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/local/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/local/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/local/X11/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/X11R6/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/local/pgm/j2sdk/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > stat64("/usr/local/pgm/mozilla-1.7.1/bin/mozilla",
    > {st_mode=S_IFREG|0755, st_size=4253, ...}) = 0
    > execve("/usr/local/pgm/mozilla-1.7.1/bin/mozilla",...) = 0
    >
    > Maybe Jakir's problem is that netscape simply isn't _in_ his PATH.
    >
    > /gordon
     
    Jakir, Aug 16, 2004
    #3
  4. Jakir

    Jakir Guest

    Same sample works on Unix-Solaris...but it fails on HP-Unix(I am
    working on version B.11.11).

    Regards
    Jakir

    (Jakir) wrote in message news:<>...
    > Thanks for the responses.
    >
    > The command "which netscape" returns "/usr/local/bin" and I had given
    > that path
    > but still it dosen't work. Also I don't get any error message. The
    > output hello is seen and then nothing happens.
    >
    > Regards
    > Jakir
    >
    > Gordon Beaton <> wrote in message news:<411c6181$>...
    > > On 13 Aug 2004 08:10:07 +0200, Tor Iver Wilhelmsen wrote:
    > > > (Jakir) writes:
    > > >> Runtime.getRuntime().exec("netscape");
    > > >
    > > > You need the explicit path to the executable. Runtime.exec() does
    > > > not see the path.

    > >
    > > Looks to me like the PATH _is_ searched:
    > >
    > > [foo]$ strace -f java Exec mozilla 2>&1 | grep mozilla
    > >
    > > stat64("/home/gordon/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/local/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/local/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/local/X11/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/X11R6/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/local/pgm/j2sdk/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > stat64("/usr/local/pgm/mozilla-1.7.1/bin/mozilla",
    > > {st_mode=S_IFREG|0755, st_size=4253, ...}) = 0
    > > execve("/usr/local/pgm/mozilla-1.7.1/bin/mozilla",...) = 0
    > >
    > > Maybe Jakir's problem is that netscape simply isn't _in_ his PATH.
    > >
    > > /gordon
     
    Jakir, Aug 18, 2004
    #4
  5. Jakir

    Jakir Guest

    Hello

    I was finally able to launch Netscape from Java application. Problem
    was with the environment variable set by Java. After setting
    XFILESEARCHPATH variable to "" I was able to start netscape through
    Java application.

    Thanks
    Jakir

    (Jakir) wrote in message news:<>...
    > Same sample works on Unix-Solaris...but it fails on HP-Unix(I am
    > working on version B.11.11).
    >
    > Regards
    > Jakir
    >
    > (Jakir) wrote in message news:<>...
    > > Thanks for the responses.
    > >
    > > The command "which netscape" returns "/usr/local/bin" and I had given
    > > that path
    > > but still it dosen't work. Also I don't get any error message. The
    > > output hello is seen and then nothing happens.
    > >
    > > Regards
    > > Jakir
    > >
    > > Gordon Beaton <> wrote in message news:<411c6181$>...
    > > > On 13 Aug 2004 08:10:07 +0200, Tor Iver Wilhelmsen wrote:
    > > > > (Jakir) writes:
    > > > >> Runtime.getRuntime().exec("netscape");
    > > > >
    > > > > You need the explicit path to the executable. Runtime.exec() does
    > > > > not see the path.
    > > >
    > > > Looks to me like the PATH _is_ searched:
    > > >
    > > > [foo]$ strace -f java Exec mozilla 2>&1 | grep mozilla
    > > >
    > > > stat64("/home/gordon/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/local/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/local/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/sbin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/local/X11/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/X11R6/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/local/pgm/j2sdk/bin/mozilla", 0x61d4149c) = -1 ENOENT
    > > > stat64("/usr/local/pgm/mozilla-1.7.1/bin/mozilla",
    > > > {st_mode=S_IFREG|0755, st_size=4253, ...}) = 0
    > > > execve("/usr/local/pgm/mozilla-1.7.1/bin/mozilla",...) = 0
    > > >
    > > > Maybe Jakir's problem is that netscape simply isn't _in_ his PATH.
    > > >
    > > > /gordon
     
    Jakir, Sep 1, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MARTIN Herve \(EXT\)
    Replies:
    1
    Views:
    1,474
    Anthony Borla
    Nov 27, 2003
  2. Lionel
    Replies:
    36
    Views:
    2,203
    Nigel Wade
    Dec 5, 2007
  3. moongeegee
    Replies:
    7
    Views:
    5,509
    Arne Vajhøj
    Oct 5, 2008
  4. Replies:
    12
    Views:
    5,061
    Roedy Green
    Apr 19, 2009
  5. SamuelXiao
    Replies:
    16
    Views:
    2,053
    Arne Vajhøj
    Sep 27, 2011
Loading...

Share This Page