FileNotFoundException - Linux

  • Thread starter Alexandr Molochnikov
  • Start date
A

Alexandr Molochnikov

I am stumped by the following strange problem:
I start a GUI-based program from Eclipse; the program successfully reads
some files from a directory. Then it launches another Java program, using
Runtime.exec(). This second Java program tries to open the same (fully
qualified) file, but throws FileNotFoundException.

This happens in Java 1.4.1 under Red Hat Linux 9. The same program works
fine under all flavors of Windows.

It almost looks like the program launched through Runtime.exec(String cmd)
does not know the environment it is in - although it is supposed to inherit
it from the parent.

Anybody faced similar problem?

Thanks for any clues.

Alex Molochnikov
Gestalt Corporation
 
I

iksrazal

Alexandr Molochnikov said:
I am stumped by the following strange problem:
I start a GUI-based program from Eclipse; the program successfully reads
some files from a directory. Then it launches another Java program, using
Runtime.exec(). This second Java program tries to open the same (fully
qualified) file, but throws FileNotFoundException.

This happens in Java 1.4.1 under Red Hat Linux 9. The same program works
fine under all flavors of Windows.

It almost looks like the program launched through Runtime.exec(String cmd)
does not know the environment it is in - although it is supposed to inherit
it from the parent.

Anybody faced similar problem?

Thanks for any clues.

Alex Molochnikov
Gestalt Corporation

I'm not sure if you mean two instances of eclipse, or eclipse and your
program.

Yet RH9 introduces a new kernel threading model, which can screw up
pre-compiled binaries using less than 1.4.1_02 .

Try setting this environment variable in your shell:

export LD_ASSUME_KERNEL=2.2.5

Its easy enough for a quick try.

iksrazal
 
A

Alex Molochnikov

I'm not sure if you mean two instances of eclipse, or eclipse and your

The first Java program is launched from Eclipse. It opens a number of files.
Then this Java program launches another Java program using Runtime.exec().
This second Java program tries to open the same files, and read the
directory they are in - only to throw FileNoFoundException on every one of
them.

The Java version is 1.4.1_03.
Yet RH9 introduces a new kernel threading model, which can screw up
pre-compiled binaries using less than 1.4.1_02 .

Try setting this environment variable in your shell:

export LD_ASSUME_KERNEL=2.2.5

Its easy enough for a quick try.

I do not use shell. Perhaps there is some way of setting it from Eclipse?
 
R

Roedy Green

Does the text in the FileNotFoundException exactly match the filenames
you were expecting? (fully qualified, you said)

Some basic steps. Dump the name of the file in the secondary process
surrounded in "" so you can tell if it has lead/trail spaces.

Dump out all the System properties in the primary and secondary
process. see http://mindprod.com/jgloss/wassup.html
 
A

Alexandr Molochnikov

I already reported the solution to my problem in the previous post. The
double quotes that surrounded arguments in the command line (passed as a
String to Runtime.exec()) were not stripped off under Linux when the
arguments were read in by the launched process' main(). One of the
parameters was a directory name and it was not recognized as such because of
it. Under Windows everything worked because there the double quotes were
stripped off before being passed to the spawned process.

One of those underwater stones that make life interesting...
 

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

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top