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

J

Jakir

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
 
L

Liz

Jakir said:
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.
 
J

Jakir

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 said:
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
 
J

Jakir

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

Regards
Jakir

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 said:
(e-mail address removed) (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
 
J

Jakir

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

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

Regards
Jakir

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 said:
On 13 Aug 2004 08:10:07 +0200, Tor Iver Wilhelmsen wrote:
(e-mail address removed) (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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top